I have a base class A, inherited by classes B and C, from which I was trying to set an instance variable. Such variable is used by methods from base class A as follows.
class A(object):
def foo(self):
print(self.value)
class B(A):
value = "B"
class C(A):
value = "C"
>>> b = B()
'B'
>>> c = C()
'C'
I understand function foo will only be evaluated during execution, which is fine as long as I do not invoke foo straight from an instance of A.
Yet, I fail to grasp how value = "B" and value = "C" manage to become self.value = "B" and self.value = "C".
Sorry if this is naive question; I have been far from python for quite a while now, and really had not seen anything quite like it. I'm using Python version 2.7.12.