[New-bugs-announce] [issue21484] More clarity needed about difference between "x += e" and "x = x + e"
report at bugs.python.org
Mon May 12 18:58:01 CEST 2014
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 += 
>>> def g(ls): ls = ls + 
>>> a = 
assignee: docs at python
nosy: Kluzniak, docs at python
title: More clarity needed about difference between "x += e" and "x = x + e"
versions: Python 3.4
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce