because it's declared as a class variable, not an instance variable.
Class variable: Once copy of variable is shared between all instances.
Instance variable: Each instance has its own value and not shared between different instances of same class.
the following code will give you false.
class a: def __init__(self): self.name = 'Adam' self.e = [1,2,3] b = a() c = a() if b.e is c.e: print('they are same') else: print("not the same")
"not the same"
* Be the first to Make Comment