[Python-ideas] Globalize lonely augmented assignment

Nick Coghlan ncoghlan at gmail.com
Mon Jun 14 04:03:58 CEST 2010

On 14/06/10 10:43, Greg Ewing wrote:
> Georg Brandl wrote:
>> They don't -- as I said in the other mail, there is no "existing scope
>> rule" that covers assignments that are implicitly global or nonlocal.
> I don't see how you come to that conclusion. You just
> need to disregard the augmented assignment and follow
> the normal rules based on the presence of plain
> assignments and global and nonlocal declarations.

What we would actually be doing is going from "augmented assignment 
determines the scope to assign to based on the same rules as normal 
assignment" to "augmented assignment determines the scope to assign to 
based on the same rules as variable referencing" (i.e. wherever we find 
the value when looking it up on the right hand side, we would put it 
back in the same place).

The semantics aren't the problem here - they can be made perfectly clear 
and reasonable. The only question is whether they are *sufficiently* 
useful to justify the effort involved in getting from the status quo to 
new (more sensible) semantics.

Keep in mind, that effort is a lot more than just a patch to CPython to 
fix our implementation, unit tests and documentation. There's also:
- doing the same thing for other implementations (e.g. Jython, 
IronPython, PyPy)
- impact on CPython branches/forks (e.g. Unladen Swallow)
- impact on Python-like languages (e.g. Cython)
- updating assorted non-PSF documentation (including books)
- updating training materials

It's for exactly these reasons that the language moratorium has been put 
in place: so we can't even be *tempted* by this kind of change until 
everyone has had a chance to at least catch up to the 3.2 state of the 

So, for this suggestion to go any further, it will need:
- a PEP (one that acknowledges this is a post-moratorium change)
- solid examples of real-world code that would be improved by this (e.g. 
from the standard library, or from major third party Python applications)

Since the most this will save anyone is the occasional global or 
nonlocal statement, I suspect the second point is going to being a 
difficult bar to achieve.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list