On Wed, Jun 27, 2018 at 5:30 PM, Paul Moore <p.f.moore at gmail.com> wrote: > But test() returns [1, 2]. So does that say (as you claim above) that > "the comprehension ran in the enclosing scope"? Doesn't it just say > that the outermost iterable runs in the enclosing scope? Yes - because the *outermost iterable* runs in the enclosing scope. But suppose you worded it like this: def test(): a = 1 b = 2 vars = {key: locals()[key] for key in locals()} return vars What would your intuition say? Should this be equivalent to dict(locals()) ? ChrisA
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