Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove array-valued default arguments from methods #56

Closed
sobolevnrm opened this issue May 30, 2020 · 2 comments · Fixed by #187
Closed

Remove array-valued default arguments from methods #56

sobolevnrm opened this issue May 30, 2020 · 2 comments · Fixed by #187
Assignees

Comments

@sobolevnrm
Copy link
Collaborator

Example in:

https://github.com/jensengroup/propka-3.1/blob/dde0d67ea5d7b0e8b24a3050ae4d6cbc4ca07972/propka/molecular_container.py#L198

Pylint finds several other examples

@sobolevnrm
Copy link
Collaborator Author

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

@orbeckst
Copy link
Collaborator

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).

@sobolevnrm sobolevnrm self-assigned this Aug 30, 2020
speleo3 added a commit to speleo3/propka that referenced this issue Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants