Op 2005-11-03, Magnus Lycka schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> There is no instance variable at that point. How can it add 2, to >> something that doesn't exist at the moment. > > Because 'a += 1' is only a shorthand for 'a = a + 1' if a is an > immutable object? Anyway, the behaviour is well documented. > > http://docs.python.org/ref/augassign.html says: > > An augmented assignment expression like x += 1 can be rewritten as x = x > + 1 to achieve a similar, but not exactly equal effect. In the augmented > version, x is only evaluated once.
Then couldn't we expect that the namespace resolution is also done only once? I say that if the introduction on += like operators implied that the same mentioning of a name would in some circumstances be resolved to two different namespaces, then such an introduction would better have not occured. Would it be too much to ask that in a line like. x = x + 1. both x's would resolve to the same namespace? -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list