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/
But the simpler dictionary compprehension `{s.replace('(+/-)',''):None for s in infts.split(', ')}` works perfectly. Shouldn't that also give the error if it was a scope issue?
Okay, so we're a in another scope inside the dictionary comprehension (all comprehensions for that matter), and only one symbol is passed to the inside. That's why `strange_reversed_working = {x+s.replace('(+/-)',''):None for x in infts.split(', ') for s in ('+','-','')}` functions, but if you reverse the order it does not. That's a real trap.
Updated example with reversed variable order for reference. This really seems to be related to , but really not the same thing. IMHO both `a` and `b` should be passed in a situation like this: ```` a = range(5) b = range(3) c = [x+y for x in a for y in b] ````