Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/data/messages/g/global-statement/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
price = 25


def add_cost():
global price # [global-statement]
price = price + 10
return price
Comment thread
gunungpw marked this conversation as resolved.
Outdated
6 changes: 6 additions & 0 deletions doc/data/messages/g/global-statement/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
price = 25


def add_cost():
total_cost = price + 10
return total_cost
Comment thread
gunungpw marked this conversation as resolved.
Outdated
3 changes: 3 additions & 0 deletions doc/data/messages/g/global-statement/related.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Official Python FAQ - global and local <https://docs.python.org/3/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python>`_
* `PEP 3104 - Access to Names in Outer Scopes <https://peps.python.org/pep-3104/>`_
* `Python global statement <https://docs.python.org/3/reference/simple_stmts.html#global>`_