[New-bugs-announce] [issue34076] Nested loop in dictionary comprehension gives `global name not defined` inside class
Jan Christoph
report at bugs.python.org
Mon Jul 9 11:57:52 EDT 2018
New submission from Jan Christoph <con-f-use at gmx.net>:
The python code:
```
class _tri(object):
infts = '(+/-)inf, (+/-)infty, (+/-)infinity'
strange_failing = {x+s.replace('(+/-)',''):None for x in ('+','-','') for s in infts.split(', ')}
```
gives a `global name 'infts' is not defined` exception, when normal dictionary comprehensions (without nested loops) and regular nested for-loops work perfectly well.
For a complete shell session and more illustrative example in versions 2.7.15 and 3.6.4 see: https://pastebin.ubuntu.com/p/9Pg8DThbsd/
----------
components: Interpreter Core
files: what_a_dict.py
messages: 321326
nosy: con-f-use
priority: normal
severity: normal
status: open
title: Nested loop in dictionary comprehension gives `global name not defined` inside class
type: behavior
versions: Python 2.7
Added file: https://bugs.python.org/file47678/what_a_dict.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34076>
_______________________________________
More information about the New-bugs-announce
mailing list