How to override inner class methods if the inner class is defined as a property of the top class
- by Maddy
I have a code snippet like this
class A(object):
class b:
def print_hello(self):
print "Hello world"
b = property(b)
And I want to override the inner class b (please dont worry about the lowercase name) behaviour. Say, I want to add a new method or I want to change an existing method, like:
class C(A):
class b(A.b):
def print_hello(self):
print "Inner Class: Hello world"
b = property(b)
Now if I create C's object as c = C(), and call c.b I get TypeError: 'property' object is not callable error. How would I get pass this and call print_hello of the extended inner class? Disclaimer: I dont want to change the code for A class.