Efanzh <[email protected]> added the comment:
I agree that this doesn’t fix any bug. But is is easy to make mistakes by using
mutable default values (See
https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments). Both
PyCharm and pylint show warnings about mutable default arguments even there is
no bug in the code.
Using `{}` as default value, by looking at the function signature, I might
wonder whether this argument stays the same on each function call, since it is
mutable. But by using `None` as default value, I am know this argument will
always be `None` on each function call. Using `None` as default value makes the
function interface more easy to understand.
Also, if some new Python coders saw `[]` or `{}` being used as default values
in the standard library, they might think “I’ll do it too since the standard
library does it”.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38654>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com