This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients Peter Eastman, r.david.murray
Date 2015-08-05.20:42:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438807321.07.0.365606208139.issue24800@psf.upfronthosting.co.za>
In-reply-to
Content
Yes it is.  The comprehension is a *new* scope, within the outer scope of the exec, and it *cannot see* the variables in the outer scope of the exec.  You have the same problem if you try to use a comprehension in that way in a class statement at the class level.  An exec is explicitly *not* equivalent to a function body.  It is equivalent to operating in a class body, if you give it two namespaces, and in a global context if you give it one.  This is documented.

Please don't reopen the issue.
History
Date User Action Args
2015-08-05 20:42:01r.david.murraysetrecipients: + r.david.murray, Peter Eastman
2015-08-05 20:42:01r.david.murraysetmessageid: <1438807321.07.0.365606208139.issue24800@psf.upfronthosting.co.za>
2015-08-05 20:42:01r.david.murraylinkissue24800 messages
2015-08-05 20:42:00r.david.murraycreate