
June 1, 2011
6:48 a.m.
On Tue, May 31, 2011 at 7:48 PM, Georg Brandl <g.brandl@gmx.net> wrote:
Because x += y is equivalent to
x = x.__iadd__(y)
and therefore an assignment is going on here. Therefore, it's only logical to treat it as such when determining scopes.
But the difference is that you can only use += if the LHS name already exists and is defined. So, it couldn't possibly be referring to a local name if it's the only assignment-like statement within a function body. How could it refer to a local if it has to refer to something that already exists?