Is it bug or feature? I checked this code with Python2 and Python3, both produce the same result
class Estimate():
def __init__(self, trials=[]):
self.t = trials
def value(self):
return sum(self.t)
def add(self, value):
self.t.append(value)
a = Estimate()
b = Estimate()
a.add(5)
print(a.value())
print(b.value())
Output:
5
5
It seems that a.t and b.t are the same object. Well I guess this is bad code practice, but still. Сan anyone please explain why this is happening?