4 ms·
In the first example under "When to use which", the reason you want to set a default argument in a function to None, check if it is None, and then set it to an
by shawnps 15y ago
In the first example under "When to use which", the reason you want to set a default argument in a function to None, check if it is None, and then set it to an empty list is explained here:
http://effbot.org/zone/default-values.htm http://effbot.org/zone/default-values.htm
In short, it can be bad to set default arguments to mutable objects because the function keeps using the same object in each call.