Repository navigation
Sync python-import with the full update of Python import - #894
Merged
Merged
Conversation
…nced Techniques and Tips - population_quiz.py: pass list(population) to random.sample(), which no longer accepts dict views (Python 3.11+) - plugins.py: replace deprecated importlib.resources.contents() with files().iterdir() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- structure/: replace setup.cfg and setup.py with a minimal pyproject.toml - population_quiz.py, population.py: read the UN WPP2024 file with importlib.resources.files() and drop the Python 3.7 backport fallback - hello_gui/__main__.py: use files() and as_file() instead of path() - population_quiz/data/README.md: point at the WPP2024 download - README.md: list tested Python versions and pinned dependencies Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
population.py loads its CSV file through importlib.resources from the `data` package, which lives in population_quiz/. From the folder root, `import population` failed with ModuleNotFoundError. The README now also spells out the setup steps for the examples that need them. Co-Authored-By: Claude Opus 5.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.
Companion to the full update of Python import: Advanced Techniques and Tips.
What changed
population_quiz/population_quiz.py:random.sample(population.keys(), ...)raisesTypeErrorsince Python 3.11. It now passeslist(population).plugins.py:importlib.resources.contents()is deprecated since Python 3.11._import_all()now usesresources.files(package).iterdir().population_quiz/population_quiz.py,population.py: read the UN WPP2024 file throughresources.files("data"), since the WPP2019 download is gone. The Python 3.7importlib_resourcesfallback is removed.hello_gui/__main__.py:resources.path()is replaced byfiles()andas_file(), matching the article.structure/:setup.cfgandsetup.pyare replaced by a minimalpyproject.toml, following learner feedback.population_quiz/data/README.md: points at the WPP2024 download and explains the unzip step.README.md: lists the tested Python versions and the pinned install command.Links
Verification (Python 3.15.1, spot checks on 3.14.9; PyYAML 6.0.3, matplotlib 3.11.2, colorama 0.4.6)
population_quiz.pyran a full quiz against the real WPP2024 CSV, and it also runs as azipapparchive.population.pyloads the data and orders countries for 2050.greeterplugins work with-W error.hello_guiopens and closes under Xvfb.python -m pip install -e .instructure/works with the newpyproject.toml, andcli.pyruns afterwards.uvx ruff@0.14.1 format --check python-importanduvx ruff@0.14.1 check python-importpass.🤖 Generated with Claude Code