Fix ModuleNotFoundError in football_final.py and misnamed weather function - #811
Open
realpython-bot wants to merge 1 commit into
Open
Fix ModuleNotFoundError in football_final.py and misnamed weather function#811realpython-bot wants to merge 1 commit into
realpython-bot wants to merge 1 commit into
Conversation
full_code/football_final.py did `import csv_reader`, but this folder only
ever shipped csv_parser.py. Anyone running the final football solution hit:
File "full_code/football_final.py", line 14, in <module>
import csv_reader
ModuleNotFoundError: No module named 'csv_reader'
The tutorial's own final listing imports csv_parser, so the module name here
was simply wrong.
Also renames get_name_and_avg -> get_day_and_avg in weather_final.py. That
function returns `day_number`, never a name, and weather_v2.py two steps
earlier already calls it get_day_and_avg -- the final file silently renamed
it. Its sibling get_name_and_diff in football_final.py is left alone,
because that one does return a team name.
Verified: both modules import cleanly and the folder's pytest suite passes
16/16 under Python 3.14 with pytest 9.1.1 and pandas 3.0.5.
Co-Authored-By: Claude Opus 5 (1M context) <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.
Found while reviewing a content update to Python Practice Problems: Parsing CSV Files.
The bug:
full_code/football_final.pydoes not runThis folder only ever shipped
csv_parser.py— there is nocsv_reader.pyin the tree, and there is none in the tutorial either. The article's own final listing importscsv_parser, so the module name here was simply wrong. Anyone downloading the materials and running the final football solution hits this immediately. Reproduced on currentmasterbefore the fix.Two call sites: the
importat line 14 and thecsv_reader.get_next_result(...)reference at line 25.Also:
get_name_and_avg→get_day_and_avginweather_final.pyThat function returns
day_number— never a name:weather_v2.py, two steps earlier in the same narrative, already calls itget_day_and_avg; the final file silently renamed it. The matching fix is going into the article in the same pass, so the two stay in sync.Its sibling
get_name_and_diffinfootball_final.pyis deliberately left alone — that one really does return a team name.Verification
ModuleNotFoundErroron unmodifiedmaster.football_finalandweather_finalimport cleanly.Known, not fixed here
README.mdstill shows a console block claimingPython 3.7.1, pytest-6.2.1, py-1.10.0, pluggy-0.13.1. That's stale against the toolchain the article now documents, but refreshing it means regenerating the sample output, which is a bigger change than this fix — worth a follow-up.Prepared during a written-content maintenance review (reviewer: Martin Breuss).
🤖 Generated with Claude Code