3 ms·
It's not ideal. For instance if I as the caller wished to provide an empty dict-like object (e.g. dict_arg=collections.OrderedDict()), then your code would sile
by moreati 10y ago
It's not ideal. For instance if I as the caller wished to provide an empty dict-like object (e.g. dict_arg=collections.OrderedDict()), then your code would silently ignore it, and use a new dict.
Instead of checking for any object that evaluates to False, you should explicitly check for None, e.g.
def func(list_arg=None, dict_arg=None):
if list_arg is None:
list_arg = []
...