[Python-ideas] Globalize lonely augmented assignment

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Jun 13 02:07:25 CEST 2010


Terry Reedy wrote:

> An augmented assignment STATEMEMT is both a STATEMENT, not an operator, 
> and an ASSIGNMENT statement.

This is just at statement of the way things are, not an
argument for keeping them that way.

> -1+ on the proposal as it will lead to confusion and bugs.

I don't see how it would lead to substantially greater
chance of bugs than there currently is for other cases
where you reference an intended local without assigning
to it. If you do that in any other way, it gets looked
up as a global, which almost certainly results in a
NameError. If the name happens to clash with an existing
global, then something more obscure happens, but that's
relatively rare.

It seems to me that getting an error message about a
global name in this case would be less confusing. The
thought process would then be "Global? Eh? But it's
supposed to be local! Oh, I see, I haven't initialised
it, how silly of me."

Whereas currently it's "Local? It's supposed to be
global, why the heck does the stupid interpreter think
it's local?" <Stares at code for 3.7 hours and then
posts a message on c.l.py.>

-- 
Greg



More information about the Python-ideas mailing list