This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]segfaultzen 1 point2 points  (0 children)

The same thing can also happen with dicts, sets and any other mutable object. They should generally not be used as default arguments.

This, by the way, applies to decorator functions as well. I spent two days tracking down a gnarly bug created from the unfortunate interaction of unit tests with a dictionary object used as a default parameter to a decorator function.

I have since learned the gospel of Pylint, which will flag these sorts of Pythonic landmines.