Why is it that the object b
has the same variables as a
and not unique ones?
class FOO:
def __init__(self):
FOO.x = [3, 1]
self.y = [9, 4]
def g(self):
FOO.x[1] = FOO.x[1] + 7
self.y *= 2
return FOO.x + self.y
a, b = FOO(), FOO()
print(a.g())
print(a.g())
print(b.g())
Why do I get this output:
[3, 8, 9, 4, 9, 4]
[3, 15, 9, 4, 9, 4, 9, 4, 9, 4]
[3, 22, 9, 4, 9, 4]
and not this?
[3, 8, 9, 4, 9, 4]
[3, 15, 9, 4, 9, 4, 9, 4, 9, 4]
[3, 8, 9, 4, 9, 4]
Isn't each object unique?