# Be careful using mutable data structures in method definitions. # # The assignment of the "foo" argument's default value is made only the # first time the function is actually evaluated on the runtime. # # Then it uses the same memory address for the default argument value, # sharing it with all instances of that class. class Foo(object): def __init__(self, foo=[]): foo.append(1) self.foo = foo Foo().foo #=> [1] Foo().foo #=> [1, 1]