[issue45862] Anomaly of eval() of list comprehension

2021-11-22 Thread Mark Dickinson
Mark Dickinson added the comment: True: there's another detail here that's needed to explain the behaviour. The first "for" clause in a list comprehension is special: it's evaluated in the enclosing scope, rather than in the local function scope that the list comprehension creates. See the

[issue45862] Anomaly of eval() of list comprehension

2021-11-22 Thread David Pratten
David Pratten added the comment: Hi Mark, Thanks.   The anomaly is that the print("eg def2", ...)  works.  Should it not fail in the same way that print("eg def4", ...) does. David On 22/11/2021 7:36:31 PM, Mark Dickinson wrote: Mark Dickinson added the comment: Thanks for the report.

[issue45862] Anomaly of eval() of list comprehension

2021-11-22 Thread Mark Dickinson
Mark Dickinson added the comment: See also #41216 -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45862] Anomaly of eval() of list comprehension

2021-11-22 Thread Mark Dickinson
Mark Dickinson added the comment: Thanks for the report. The behaviour is by design: see #5242 (especially msg81898) for an explanation. Closing this issue as a duplicate of #5242. -- nosy: +mark.dickinson resolution: -> duplicate stage: -> resolved status: open -> closed

[issue45862] Anomaly of eval() of list comprehension

2021-11-21 Thread David Pratten
New submission from David Pratten : Hi Example "eg def2" works but "eg def4" gives an error? David ``` emp = [ { "empno": 7839, "mgr": 0, "ename": "KING" }, { "empno": 7566, "mgr": 7839, "ename": "JONES" }, {