Modifies sentence and provides link to explanation of mutable defaults gotcha in the documentation #1251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Modifies existing sentence and provides link to an explanation of the common gotcha of mutable default parameters for functions/methods. The change occurs on the "Initialization" page (
init.html
/init.md
) of the documentation.The change adds a link is to this section on python-guide.org. I have no connection to python-guide.org — I just like their explanation and would be happy to change it, if you have a better replacement in mind.
Justification
The documentation already states that mutable default arguments (probably) don't work as expected and alludes to similar gotcha with function/method parameters. I think it could be helpful to provide link to an simple explanation to understand the connection the two situations.
There are many other precedents in the documentation for providing helpful links, for example, "Subclassing considered bad" and "think twice before using pickle"... and this is something that makes me really appreciate
attrs
documentation.Pull Request Check List
.rst
and.md
files is written using semantic newlines.