How can I overload class methods?
I failed with:
class D(object):
def create(self):
foo = 100
bar = 'squirrels'
baz = 'I have %d insane %s in my head.' % (foo, bar)
return baz
class C(D):
def create(self):
super(C, self).create()
baz = 'I have %s cute %s in my yard.' % (self.foo, self.bar)
C().create()
Traceback was:
AttributeError: 'C' object has no attribute 'foo'
You have tried to use local variables as class attributes. Try to do the following changes: