class Foo:
def __init__(self):
self.A = 100
class Boo(Foo):
def __init__(self):
super(Boo, self).__init__()
self.B = None
x = Boo()
print(x.A, x.B)
# 100 None
As shown above, I've created an instance of Boo
with attributes A
and B
. Now I'd like to assign value to attributes only if they are created during __init__
. i.e. if I set x.A=0
it will work, but when I want to set value to a new attribute x.C=False
it should do nothing.