
Alex Martelli wrote:
My slight preference for leaving += and friends alone is that a function using them to rebind nonlocals would be hard to read, that since the change only applies when the LHS is a bare name the important use cases for augmented assignment don't apply any way, that it's a bit subtle to explain that foo.bar += baz ( += on a dotted name) implies a plain assignment (setattr) on foo.bar while foo_bar += baz ( += on bare name) might imply a := assignment (rebinding a nonlocal) IF there are no "foo_bar = baz" elsewhere in the same function BUT it would imply a plain assignment if there ARE other plain assignments to the same name in the same function, ...
To an extent you're only making it _more_ difficult by saying "x := ..." rebinds to a non-local name" instead of "x := rebinds to x in whichever scope x is defined (which may be the local scope)". With the latter definition, there's less to explain regarding "x += ..." as a rebinding operation. I find that _if_ we were to add a rebinding operator, it would be extremely silly not to allow augmented assignments to be rebinding, perhaps even patronizing: "yes you can assign to outer scopes, but no you can't use augmented assignments for that since we think it makes it too difficult for you." We should either _not_ allow assignments to outer scopes at all, _or_ allow it and make it as powerful as practically possible. I don't think allowing it with non-obvious (arbitrary) limitations is a good idea. For example, the more I think about it, the more I am _against_ disallowing "a, b := b, a". That said, someone made a point here that rebinding is a behavior of a variable, not the assignment operation: that's a very good one indeed, and does make me less certain of whether adding := would be such a good idea after all. Just