> x=7 > def f(): > global x > def g(): > exec "x=3" > return x > print g() > > f() > > prints 3, not 7. I've been meaning to reply to your original post on this subject, which actually addresses two different issues -- global and exec. The example above will fail with a SyntaxError in the nested_scopes future, because of exec in the presence of a free variable. The error message is bad, because it says that exec is illegal in g because g contains nested scopes. I may not get to fix that before the beta. The reasoning about the error here is, as usual with exec, that name binding is a static or compile-time property of the program text. The use of hyper-dynamic features like import * and exec are not allowed when they may interfere with static resolution of names. Buy that? Jeremy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4