I'm puzzled with python the more I get into it.
For example the following code:
class A:
def __init__ (self):
self.test = "a"
def dump(self):
print("A.test: %s" % (self.test,))
print("A.test: %s" % (self.__dict__["test"],))
print("A.test: %s" % (getattr(self, "test"),))
print()
class B (A):
def __init__ (self):
self.test = "b"
def dump(self):
print("B.test: %s" % (self.test,))
print("B.test: %s" % (self.__dict__["test"],))
print("B.test: %s" % (getattr(self, "test"),))
print()
o = B ()
o.dump()
A.dump(o)
super(B, o).dump()
prints:
B.test: b
B.test: b
B.test: b
A.test: b
A.test: b
A.test: b
A.test: b
A.test: b
A.test: b
which seems to show that you can call a function of a base class but if that class has an attribute which was also used in some derived class you can't access this attribute by using the normal object.attribute notation or perhaps you can't access it at all.
Is that really true? If so it would kill - IMHO - the whole python object model.