New submission from Feliks:

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]

----------
assignee: docs@python
components: Documentation
messages: 218338
nosy: Kluzniak, docs@python
priority: normal
severity: normal
status: open
title: More clarity needed about difference between "x += e" and "x = x + e"
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21484>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to