Message136722
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?)
For example:
x=0
def count(i):
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. |
|
Date |
User |
Action |
Args |
2011-05-24 05:57:37 | Lukas.Petru | set | recipients:
+ Lukas.Petru |
2011-05-24 05:57:37 | Lukas.Petru | set | messageid: <1306216657.18.0.255448168009.issue12165@psf.upfronthosting.co.za> |
2011-05-24 05:57:36 | Lukas.Petru | link | issue12165 messages |
2011-05-24 05:57:36 | Lukas.Petru | create | |
|