I have two class instances as follows
class Foo:
def __init__(self, a = 5):
self.a = a
f1 = Foo()
f2 = Foo()
Now when I compare the two, f1 is f2
evaluates to False
obviously. However, f1.a is f2.a
is True
. This is a big problem when a
is a list like object. How does this happen and how do I get around this (without hardcoding a
's value inside __init__
)?
I am aware of this and this questions. But they do not answer how I am getting this behavior with no class variable a
.