Skip to content

Sync python-variables with the updated tutorial - #976

Merged
realpython-bot merged 2 commits into
masterfrom
maintenance/python-variables-20261201
Dec 2, 2026
Merged

realpython-bot merged 2 commits into
masterfrom
maintenance/python-variables-20261201

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

Syncs python-variables/ with the full update of Variables in Python: Usage and Best Practices (update draft: https://realpython.com/pbjt/blog/post/2377/change/, card: https://trello.com/c/zUQmtcUc).

What changed:

  • config.py: added. The tutorial imports settings from it, but the folder didn't have it.
  • matrix.py: uses the enumerate() loop from the updated tutorial, so i and j are real row and column indices.
  • scopes.py and employees.py: the module-level demo calls now sit under if __name__ == "__main__":. Before, from scopes import outer_func printed on import and from employees import Employee started Employee.count at 2, so neither matched the tutorial's REPL sessions.
  • README.md: added Setup and Usage sections. The code uses only the standard library.

Verified on CPython 3.15.2: every script runs and its output matches the article. The REPL imports (scopes, employees, config, timeout) give the article's output too. ruff@0.14.1 format --check, ruff check, and dircheck.py all pass.

🤖 Generated with Claude Code

realpython-bot and others added 2 commits December 1, 2026 13:17
Add config.py, switch matrix.py to the enumerate() loop, guard the
module-level demo calls in scopes.py and employees.py so imports match
the tutorial's REPL sessions, and add Setup/Usage to the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@realpython-bot
realpython-bot merged commit 2e9d0d3 into master Dec 2, 2026
1 check passed
@realpython-bot
realpython-bot deleted the maintenance/python-variables-20261201 branch December 2, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant