[issue21484] More clarity needed about difference between x += e and x = x + e
Raymond Hettinger added the comment: I agree with Josh. If anything this belongs in a wiki entry, faq page, or stack overflow question. -- nosy: +rhettinger resolution: - rejected status: open - closed ___ 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
[issue21484] More clarity needed about difference between x += e and x = x + e
Changes by Terry J. Reedy tjre...@udel.edu: -- nosy: +terry.reedy ___ 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
[issue21484] More clarity needed about difference between x += e and x = x + e
Feliks added the comment: Well, there is some anecdotal evidence. ;-) I happen to have a lot of experience with a lot of programming languages, and I was bitten by this. Let's put it like this: it is quite easy to overlook the significance of the sentence in question. One looks at the paragraph, reads the stuff about evaluation, thinks of course and moves on. If the sentence were in a new paragraph, and instead of with Also began with something like More importantly, then it might have drawn more attention. After all, the drastic semantic difference between the two forms is quite unlike what one is used to from programming in, say, C. I think it would be helpful if it were stressed a little bit more. -- ___ 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
[issue21484] More clarity needed about difference between x += e and x = x + e
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
[issue21484] More clarity needed about difference between x += e and x = x + e
Josh Rosenberg added the comment: It seems to me like that is one of the most obvious consequences. How is this not an immediately obvious consequence? -- nosy: +josh.rosenberg ___ 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