Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2950776d
Kaydet (Commit)
2950776d
authored
Haz 05, 2016
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
[merge from 3.5] - Issue27203 - Fix doctests Doc/faq/programming.rst.
Patch contributed by Jelle Zijlstra.
üst
7a9ddd1d
77493201
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
programming.rst
Doc/faq/programming.rst
+20
-8
No files found.
Doc/faq/programming.rst
Dosyayı görüntüle @
2950776d
...
@@ -1172,16 +1172,28 @@ You probably tried to make a multidimensional array like this::
...
@@ -1172,16 +1172,28 @@ You probably tried to make a multidimensional array like this::
>>> A = [[None] * 2] * 3
>>> A = [[None] * 2] * 3
This looks correct if you print it::
This looks correct if you print it:
.. testsetup::
A = [[None] * 2] * 3
.. doctest::
>>> A
>>> A
[[None, None], [None, None], [None, None]]
[[None, None], [None, None], [None, None]]
But when you assign a value, it shows up in multiple places:
But when you assign a value, it shows up in multiple places:
>>> A[0][0] = 5
.. testsetup::
>>> A
[[5, None], [5, None], [5, None]]
A = [[None] * 2] * 3
.. doctest::
>>> A[0][0] = 5
>>> A
[[5, None], [5, None], [5, None]]
The reason is that replicating a list with ``*`` doesn't create copies, it only
The reason is that replicating a list with ``*`` doesn't create copies, it only
creates references to the existing objects. The ``*3`` creates a list
creates references to the existing objects. The ``*3`` creates a list
...
@@ -1665,9 +1677,9 @@ address, it happens frequently that after an object is deleted from memory, the
...
@@ -1665,9 +1677,9 @@ address, it happens frequently that after an object is deleted from memory, the
next freshly created object is allocated at the same position in memory. This
next freshly created object is allocated at the same position in memory. This
is illustrated by this example:
is illustrated by this example:
>>> id(1000)
>>> id(1000)
# doctest: +SKIP
13901272
13901272
>>> id(2000)
>>> id(2000)
# doctest: +SKIP
13901272
13901272
The two ids belong to different integer objects that are created before, and
The two ids belong to different integer objects that are created before, and
...
@@ -1676,9 +1688,9 @@ objects whose id you want to examine are still alive, create another reference
...
@@ -1676,9 +1688,9 @@ objects whose id you want to examine are still alive, create another reference
to the object:
to the object:
>>> a = 1000; b = 2000
>>> a = 1000; b = 2000
>>> id(a)
>>> id(a)
# doctest: +SKIP
13901272
13901272
>>> id(b)
>>> id(b)
# doctest: +SKIP
13891296
13891296
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment