Sync python-function with the updated tutorial - #840
Open
realpython-bot wants to merge 1 commit into
Open
realpython-bot wants to merge 1 commit into
realpython-bot wants to merge 1 commit into
Conversation
… Python Function Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Companion-code sync for the maintenance update of Defining Your Own Python Function.
What changed
python-function/mutable_argument.py— the mutable-default-argument example had drifted away from the tutorial. The folder definedadd_product(item, inventory=[])and called it with"apple"/"banana", but the article's "Using Mutable Default Values" section definesappend_to(item, target=[])and calls it with1,2,3.add_product()appears nowhere in the tutorial, so a reader downloading the materials couldn't match the file to the text. The script now transcribes the article's block exactly, and its output ([1],[1, 2],[1, 2, 3]) matches the tutorial's output character for character.What this cycle changed in the article, and why nothing else moved here
The update's code-family fix was the
print(average.__doc__)output block, dedented for the Python 3.13+ docstring-whitespace stripping — that's a REPL output block with no twin in this folder (average.pycarries the undocumentedaverage(), and there is no docstring script). The rest of the cycle was prose: fourteen{% ref %}glossary links, the PEP 257 link repointed topeps.python.org, and a factual fix to the mutable-default wording. Thedependenciespin moved frompython==3.13topython==3.14; this folder has norequirements.txtorconstraints.txt(the examples are pure standard library), so there is nothing to re-pin — the repo root already targetspy314.How this was verified
uvvenv on the article's new pin, CPython 3.14.6 (python==3.14).python-function/executed to completion with exit 0 underMPLBACKEND=Agg;mutable_argument.py's output was diffed against the article'spyconblock.requirements.txt(ruff==0.14.1):uvx ruff@0.14.1 format --check python-function→17 files already formatteduvx ruff@0.14.1 check python-function→All checks passed!Needs a human merge.
🤖 Generated with Claude Code