[New-bugs-announce] [issue12165] Does nonlocal include global?
report at bugs.python.org
Tue May 24 07:57:37 CEST 2011
New submission from Lukas Petru <lukas.petru at seznam.cz>:
Can "nonlocal x" declaration also reference global x? I would assume that global scope automatically encloses all other scopes. But the nonlocal keyword seems to exclude global scope. This seems counter-intuitive. (maybe bug in implementation?)
nonlocal x; x+=i; return x;
Checking this code in IDLE gives: no binding for nonlocal 'x' found. If this is what was intended, maybe it should be more clearly written in the documentation.
I am coming to Python from Lisp, so I am still learning Python's principles.
components: Interpreter Core
title: Does nonlocal include global?
versions: Python 3.2
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce