Sync python-set with the updated tutorial - #839
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
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 Sets in Python (post 152).
What changed and why
The update draft re-pins the tutorial to Python 3.14 and corrects several
transcripts. Four of the scripts in
python-set/no longer produce what thetutorial shows, so they're brought back in line:
pop.py— this cycle'soutput-driftfix added the echoed return values(
'Laura','Alice') to the two bareemployees.pop()calls in the article'sREPL block. Those two calls were bare in the script too, so the script printed
nothing for them. They now
print(), so the script shows four popped elementsand only the fifth call raises
KeyError: 'pop from an empty set', exactly asthe tutorial does.
superset.py— the "Supersets" section showsavailable_ingredients.issuperset(required_ingredients)returningTrue, butthe script called
.issubset()and printedFalse, contradicting the article.Fixed to
.issuperset().difference_update.py— the file ended with a baretodo_listexpression,so running it printed nothing at all. The article echoes the updated set, so
this is now
print(todo_list).union.py—a.union(b, c, d)discarded its result while the articleechoes
{1, 2, 3, 4, 5, 6, 7}. Now printed.No dependency file is involved: the tutorial's
dependenciesfield ispython==3.14with no third-party packages, andpython-set/ships norequirements.txt. The Python 3.14 bump needed no code change — every scriptalready runs clean on 3.14.
Nothing else in the folder was touched. The three Python 3.14 traceback-wording
fixes in the article (
TypeError: cannot use 'list' as a set element ...,... cannot use 'tuple' as a set element ...,TypeError: set.symmetric_difference() takes exactly one argument (2 given)) have no twinhere — those failing snippets are not part of any script.
How this was verified
python-set/executed withMPLBACKEND=Agg. All exit 0except
pop.pyandremove.py, which end on theKeyErrorthe tutorialdeliberately demonstrates. Output was compared against the article's blocks
(set-iteration ordering aside, which is unordered by nature).
requirements.txt:uvx ruff@0.14.1 format --check python-set→ 22 files already formatted;uvx ruff@0.14.1 check python-set→ All checks passed!🤖 Generated with Claude Code