[Python-Dev] replacing 'global'

Just van Rossum just at letterror.com
Sun Oct 26 12:31:22 EST 2003


Alex Martelli wrote:

> > - I think augmented assignments CAN be made "rebinding" without
> > breaking code, since currently a += 1 fails if a is neither local
> > nor global.
> 
> You are right about the breaking code, but I would still slightly
> prefer to eschew this just for simplicity -- see also below.
[ ... ]
> I think rebinding nonlocals should be rare enough that the fact of
> having to write e.g. "a := a+1" rather than "a += 1" is a very minor
> problem. [ ... ]

Minor, sure, but I think it's an unnecessary restriction, just like many
people think Python's current inability to assign to outer scopes is
unneccesary. If we have a rebinding operator, it'll be very surprising
if augmented assignment ISN'T rebinding. It's just such a natural fit.

Just



More information about the Python-Dev mailing list