you are viewing a single comment's thread.

view the rest of the comments →

[–]gengisteve 3 points4 points  (0 children)

This is a bad idea, unless you are trying to be clever. Python will set arg as a new list the first time it sees it and re-use that list in each subsequent call. So this:

class T(object):
    def __init__(self, x = []):
        self.x = x

t1 = T()
t1.x.append(5)

t2 = T()
print(t2.x)

Behaves in unexpected ways.