Skip to content

Sync python-variables with the updated tutorial - #976

Open
realpython-bot wants to merge 1 commit into
masterfrom
maintenance/python-variables-20261201
Open

realpython-bot wants to merge 1 commit 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

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>

This branch has not been deployed

No deployments
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