Chris Angelico wrote:
# Python def outer(): x = 0 def inner(): nonlocal x x += 2Is it better to say "nonlocal" on everything you use than to say "self.x" on each use?
I've not used Python closures since nonlocal came about, but AFAIK you only need to use nonlocal if there's an assignment to the variable in the scope. Maybe an augmented assignment creates the same constraint but logically it shouldn't.
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
