[New-bugs-announce] [issue29008] Can't do dict comp from previously defined dict in the outermost scope of class defintion
Dan Snider
report at bugs.python.org
Sun Dec 18 22:17:19 EST 2016
New submission from Dan Snider:
class MyClass:
a_dict = {'key':'value'}
r_dict = {a_dict[k]:k for k in a_dict}
throws the error:
Traceback (most recent call last):
File "C:/Users/D/AppData/Local/Programs/Python/Python35-32/deleteme.py", line 1, in <module>
class MyClass:
File "C:/Users/D/AppData/Local/Programs/Python/Python35-32/deleteme.py", line 3, in MyClass
r_dict = {a_dict[k]:k for k in a_dict}
File "C:/Users/D/AppData/Local/Programs/Python/Python35-32/deleteme.py", line 3, in <dictcomp>
r_dict = {a_dict[k]:k for k in a_dict}
NameError: name 'a_dict' is not defined
----------
assignee: terry.reedy
components: IDLE, Interpreter Core, Windows
messages: 283575
nosy: Assume_Away, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Can't do dict comp from previously defined dict in the outermost scope of class defintion
type: behavior
versions: Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29008>
_______________________________________
More information about the New-bugs-announce
mailing list