>>>>> "SM" == Skip Montanaro <skip@mojam.com> writes: Guido> Sigh indeed.... It sounds like the real source of frusteration was the confusing error message. I'd rather fix the error message. Guido> How about the old fallback to using straight dict lookups Guido> when this combination of features is detected? Straight dict lookups isn't sufficient for most cases, because the question is one of whether to build a closure or not. def f(): from module import * def g(l): len(l) If len is not defined in f, then the compiler generates a LOAD_GLOBAL for len. If it is defined in f, then it creates a closure for g (MAKE_CLOSURE instead of MAKE_FUNCTION) generator a LOAD_DEREF for len. As far as I can tell, there's no trivial change that will make this work. SM> This probably won't be a very popular suggestion, but how about SM> pulling nested scopes (I assume they are at the root of the SM> problem) until this can be solved cleanly? Not popular with me <0.5 wink>, but only because I don't there this is a problem that can be "solved" cleanly. I think it's far from obvious what the code example above should do in the case where module defines the name len. Posters of c.l.py have suggested both alternatives as the logical choice: (1) import * is dynamic so the static scoping rule ignores the names it introduces, (2) Python is a late binding language so the name binding introduced by import * is used. 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