class A():
class B():
def Foo(self):
print "Hello"
class C():
def Bar(self):
print "Goodbye"
def name(self):
print "FooBar"
What I want to do is, within the Bar function is call the Foo function. How would I do that?
In Python, inner classes don’t have an implicit instance of the outer class associated with them. Without such an instance, you can’t call
A‘s non-static methods fromBorC.If you do have such an instance, then simply use the dot notation:
(where
self.ais an instance ofA.)Alternatively, if
A.name()can be made static, the following will also work: