I'm trying to initialize an inheriting class inside another class, but it doesn't work and I don't know how to solve.
I've read here that inheriting generally works following way:
class Foo(object):
def __init__(self, text):
print text
class Bar(Foo):
def __init__(self, text):
super(Bar, self).__init__(text)
This works, however, if I put the Bar
-class into another class, the code doesn't work anymore.
class Whatever(object):
class Bar(Foo):
def __init__(self, text):
super(Bar, self).__init__(text)
def __init__(self, text):
test = self.Bar(text)
Python gets confused with the namespace:
super(Bar, self).__init__(text)
NameError: global name 'Bar' is not defined
What to do? Thanks!