How to access outer class attribute from nested class
Heiko Henkelmann
heiko at hhenkelmann.de
Tue Apr 27 14:38:30 EDT 2004
Please see the following example. Is there any other way to access
SomeAttribute from the nested class, without having to use the actual
name of the outer class?
class SomeClass:
SomeAttribute = 1
class SomeNestedClass:
SomeOtherAttribute = 2
def SomeNestedClassMethod(cls):
print "%s%s" % (
SomeClass.SomeAttribute
cls.SomeOtherAttribute,
)
SomeNestedClassMethod = classmethod(SomeNestedClassMethod)
Thanx
More information about the Python-list
mailing list