Namespace puzzle, list comprehension fails within class definition

John Ladasky john_ladasky at sbcglobal.net
Mon Jan 12 15:43:27 EST 2015


Following up to myself: I finally did the right keyword search, and found a relevant article:

http://stackoverflow.com/questions/13905741/accessing-class-variables-from-a-list-comprehension-in-the-class-definition

Maybe I HAVE tried to define a list comprehension inside a class definition before.  What I tried to do would have apparently worked in Python 2.  But in Python 3, the namespace behavior has changed (and I'm still reading the article to understand how and why).

I guess that I could define my objects as globals... now, why would Python force me into doing that? :^(



More information about the Python-list mailing list