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
b3a57922
Kaydet (Commit)
b3a57922
authored
May 21, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge #17973: fix technical inaccuracy in faq entry (it now passes doctest).
üst
3ee6dabf
95ae9920
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
programming.rst
Doc/faq/programming.rst
+8
-5
No files found.
Doc/faq/programming.rst
Dosyayı görüntüle @
b3a57922
...
...
@@ -1131,7 +1131,7 @@ a tuple points to.
Under the covers, what this augmented assignment statement is doing is
approximately this::
>>> result = a_tuple[0]
.__iadd__(1)
>>> result = a_tuple[0]
+ 1
>>> a_tuple[0] = result
Traceback (most recent call last):
...
...
...
@@ -1154,16 +1154,19 @@ that even though there was an error, the append worked::
>>> a_tuple[0]
['foo', 'item']
To see why this happens, you need to know that for lists, ``__iadd__`` is equivalent
to calling ``extend`` on the list and returning the list. That's why we say
that for lists, ``+=`` is a "shorthand" for ``list.extend``::
To see why this happens, you need to know that (a) if an object implements an
``__iadd__`` magic method, it gets called when the ``+=`` augmented assignment
is executed, and its return value is what gets used in the assignment statement;
and (b) for lists, ``__iadd__`` is equivalent to calling ``extend`` on the list
and returning the list. That's why we say that for lists, ``+=`` is a
"shorthand" for ``list.extend``::
>>> a_list = []
>>> a_list += [1]
>>> a_list
[1]
is equivalent to::
This
is equivalent to::
>>> result = a_list.__iadd__([1])
>>> a_list = result
...
...
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