re: Python Mutable Defaults Are The Source of All Evil VIEW POST


Another option is using a non mutable type like a tuple


Yep, that would solve it if your argument can be transformed to use a non-mutable version.
However, Python is already so confusing on types that I wouldn’t recommend providing a tuple if you’re to use a list afterwards.
I like to use type annotations, so annotating an argument as a List while providing an empty tool for the default would look suspicious. ;)

code of conduct - report abuse