I tried to inherit a method and use it to access a variable defined in my subclass. Here's a very simple example of what I mean:
class A(object):
def __init__(self):
self.__type='parent'
def type(self):
return self.__type
class B(A):
def __init__(self):
super(B,self).__init__()
self.__type='child'
x=B()
print x.type()
Python returns 'parent' as the result. I assume this is something to do with the method type being defined within the scope of class A and can only access things defined in class A.
What's considered the most elegant way to avoid defining my method in my sub class?