Closed sobolevnrm closed 8 months ago
In general, I need to better understand the general problems behind mutable default values. https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
My understanding is that unless one really wants to keep track of multiple function invocations in a global variable that is effectively hidden from global view, one should just follow the advice in the quantifiedcode link and use def(value=None)
and value = value if value is not None else []
(or similar).
Example in:
https://github.com/jensengroup/propka-3.1/blob/dde0d67ea5d7b0e8b24a3050ae4d6cbc4ca07972/propka/molecular_container.py#L198
Pylint finds several other examples