[issue35273] 'eval' in generator expression behave different in dict from list

yesheng report at bugs.python.org
Mon Nov 19 01:24:19 EST 2018


New submission from yesheng <13611358285 at 139.com>:

def yyy():
    a, b = 'abc', 'abd'
    print([eval(i) for i in ('a', 'b')])


def zzz():
    a, b = 'abc', 'abd'
    print({i: eval(i) for i in ('a', 'b')})


yyy()  # ok
zzz()  # NameError: name 'a' is not defined, however in yyy() it is ok

----------
messages: 330073
nosy: yesheng
priority: normal
severity: normal
status: open
title: 'eval' in generator expression behave different in dict from list
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35273>
_______________________________________


More information about the Python-bugs-list mailing list