Namespace puzzle, list comprehension fails within class definition
john_ladasky at sbcglobal.net
Mon Jan 12 21:49:45 CET 2015
On Monday, January 12, 2015 at 12:41:30 PM UTC-8, Ethan Furman wrote:
> In Foo 'f' is part of an unnamed namespace; the list comp 'g' has its own namespace, effectively making be a nonlocal;
> class name lookup skips nonlocal namespaces.
> Workaround: use an actual for loop.
Thanks, Ethan. That works.
As you can see from my other post, I've just discovered that the scoping rules for list comprehensions were changed between Py2 and Py3.
More information about the Python-list