[Python-ideas] Globalize lonely augmented assignment
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun Jun 13 02:49:46 CEST 2010
Georg Brandl wrote:
> Yes, but why does that make the current semantics broken?
The current semantics perversely make certain code useless
that would otherwise have an obvious and useful interpretation.
Maybe "suboptimal" would be a better adjective.
>Am 12.06.2010 21:40, schrieb Bruce Frederiksen:
>>
>> def foo():
>> # without an assignment to 'a', this is currently always an error!
>> # it can only make sense if 'a' is global!
>> a += 7
>>
>>If you can't do that, then this is a bug!
>
> Yes, it is a bug -- a bug in your code.
But if the programmer intended a to be global, the *only*
reason it's a bug is the current somewhat arbitrary
interpretation placed on the augmented assignment.
--
Greg
More information about the Python-ideas
mailing list