Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018年6月27日 00:55:00 -0700

On Wed, Jun 27, 2018 at 5:30 PM, Paul Moore <[email protected]> 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
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to