> They are. You've stiumbled on one of those Python peculiarities of > implementation that can be useful and annoying in equal measure. > >> class Test(object): >> def __init__(self, name, paths=[]): >> self.name = name >> self.paths = paths > > When you give a function/method a default value that same object is used > for *every* invocation of the method where the default applies.
By the way, this is one of the things that tools like pylint (https://www.pylint.org/) will warn about. http://pylint-messages.wikidot.com/messages:w0102 Just to note that there are external "lint" tools that can help catch this class of problems automatically. Best of wishes! _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor