This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Kluzniak
Recipients Kluzniak, docs@python
Date 2014-05-12.16:58:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1399913881.84.0.586979222354.issue21484@psf.upfronthosting.co.za>
In-reply-to
Content
In Sec. 7.2.1 of the Language Reference, in the description of "+=" we have: "Also, when possible, the actual operation is performed in-place, meaning that rather than creating a new object and assigning that to the target, the old object is modified instead."
Although this is quite accurate, not all the consequences are immediately obvious, and sometimes they are quite serious.  I would suggest adding a note that points the reader's attention in particular to the phenomenon exhibited in the following example:
>>> def f(ls):  ls += [2]
... 
>>> def g(ls):  ls = ls + [2]
... 
>>> a = [1]
>>> g(a)
>>> a
[1]
>>> f(a)
>>> a
[1, 2]
History
Date User Action Args
2014-05-12 16:58:01Kluzniaksetrecipients: + Kluzniak, docs@python
2014-05-12 16:58:01Kluzniaksetmessageid: <1399913881.84.0.586979222354.issue21484@psf.upfronthosting.co.za>
2014-05-12 16:58:01Kluzniaklinkissue21484 messages
2014-05-12 16:58:01Kluzniakcreate