I am learning OOP in python, and I am surprised to find in another post that a parent class can access a class variable defined in child, like the example below. I can understand that child can access a class variable defined in parent bc of inheritance (or is it not inheritance but something else?). What makes this possible and does it imply a pool of class variables that a subclass can adds to (and its superclasses can access) when it inherits from a superclass?
class Parent(object):
def __init__(self):
for attr in self.ATTRS: // accessing class variable defined in child?
setattr(self, attr, 0)
class Child(Parent):
#class variable
ATTRS = ['attr1', 'attr2', 'attr3']
def __init__(self):
super(Child, self).__init__()