Scope and classes
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Wed Aug 19 05:18:59 EDT 2009
Chris Rebert a écrit :
(snip)
> To access class-level variables from within instance methods of the
> class, you have 2 options:
> A. Use the class name, i.e. Abc.message
> B. Reference the class indirectly, i.e. self.__class__.message
Or even simpler - *if* there's no synonym instance attribute:
=> self.message
Attribute lookup will try to resolve the attribute name on the class
(and it's parent classes) if it's not found on the instance.
More information about the Python-list
mailing list