Scope and classes
davidshais at googlemail.com
Wed Aug 19 00:47:09 CEST 2009
I'm trying to understand how scopes work within a class definition.
I'll quickly illustrate with an example. Say I had the following class
message = 'Hello World'
>>> instance = Abc()
NameError: global name 'message' not defined
My question is, why? message is not defined in print_message, but it
is defined in the enclosing scope (the class)?
More information about the Python-list