On 12/06/10 07:06, Fake Name wrote:
Mark Dickinson suggested discussion take place here, rather than at bugs.python
http://bugs.python.org/issue8977
To note, his counter example would currently raise an UnboundLocalError
For those not checking the issue discussion, I'll note that Guido's opinion is that this is a borderline case. Either behaviour (mutate/rebind the global or raise UnboundLocalError) is going to be confusing in some cases and intuitive in others. To quote Mark: """ I guess there's a mismatch either way around: currently, "A += [4]" and "A.append(4)" behave differently for (e.g.,) a list A. With the proposed change, "n += 3" and "n = n + 3" behave differently for a integer n.""" I agree with both of those points. However, I believe this is a case where the cognitive cost of changing the status quo isn't worthwhile. New Python users can be taught very quickly that assigning to a variable from a different scope requires a global or nonlocal declaration. While existing users could be taught easily enough that that was no longer necessary for augmented assignment, how much real world code would actually benefit? (now, Paul Graham's accumulator hobby horse doesn't count as real world code) Call it a -0. I'm not implacably opposed, I just don't see it as a good use of developer (and documentation author!) time. Cheers, Nick. P.S. Any such change would have to wait until after the moratorium anyway. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------