Sync python-while-loop with the updated tutorial - #834
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
…ops: Repeating Tasks Conditionally 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.
Brings
python-while-loop/back in line with the current state of Python while Loops: Repeating Tasks Conditionally, which has just been through a maintenance update.What changed and why
for_loop.py— output drift (the reason this PR exists).The script printed
"\nWith a for-loop"/"\nWith a while-loop", but the tutorial's code block and its$ python for_loop.pyconsole block both show the headings unhyphenated. This cycle's update corrected the console block to the unhyphenated text, so the shipped script was the last thing still printing hyphens. Now dehyphenated to match; the script's stdout is byte-for-byte identical to the console block in the article.connection.py— value drift.time.sleep(0.5)->time.sleep(0.3), matching the tutorial's code block.break.py,continue.py,guess.py— missing files. The tutorial presents all three as named, downloadable scripts (```python filename="break.py"etc., plus$ python break.py/$ python continue.pyconsole blocks), but they were never added to this folder. Added verbatim from the article's code blocks. Their output matches the tutorial's console blocks exactly.Not changed, deliberately
temperature.py,password.py,user_input.py, and the second gap infor_loop.py). These are CMS display compression, not drift — applyingtemperature.py's article spacing verbatim would put one blank line around a top-leveldefand failruff format --check. The repo's PEP 8 spacing is kept.user_input.pykeeps the trailing walrus-operator loop. The tutorial shows that variant as apyconblock rather than a named file, which is the same convention already used forinfinite.pyandremove.pyin this folder.requirements.txt. The tutorial'sdependenciesfield ispython==3.14with no third-party packages, and every script here is stdlib-only (random,time,pathlib). There is nothing for a reader to install, so no requirements file is added.api_calls.py,logfile.py,process_pairs.pyare left in place. They no longer correspond to anything in the current article text, but they've been part of this folder since it was created and removing reader-facing files is an editorial call rather than a sync fix. Flagging for a human.How this was verified
python==3.13->python==3.14bump is part of this update cycle).MPLBACKEND=Aggset. The interactive ones (user_input.py,password.pyon both the success and lockout paths,guess.py) were driven with piped stdin;check_file.pyandlogfile.pywere driven by a background writer creatinghello.txt/ appending tofile.log;temperature.pyandapi_calls.pyran to natural termination.break.py,continue.py, andfor_loop.pydiffed against the corresponding console blocks in the tutorial — exact match.requirements.txtpins,ruff==0.14.1:ruff format --check python-while-loop->14 files already formatted;ruff check python-while-loop->All checks passed!.Needs a human merge.
🤖 Generated with Claude Code