New submission from Jan Christoph <con-f-...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue34076>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to