Skip to content

Commit 86cdfaa

Browse files
gh-48496: Added example and link to faq for UnboundLocalError in reference (GH-93068)
(cherry picked from commit f3db68e) Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
1 parent de74d49 commit 86cdfaa

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Doc/faq/programming.rst

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ Yes. The coding style required for standard library modules is documented as
113113
Core Language
114114
=============
115115

116+
.. _faq-unboundlocalerror:
117+
116118
Why am I getting an UnboundLocalError when the variable has a value?
117119
--------------------------------------------------------------------
118120

Doc/reference/executionmodel.rst

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ lead to errors when a name is used within a block before it is bound. This rule
128128
is subtle. Python lacks declarations and allows name binding operations to
129129
occur anywhere within a code block. The local variables of a code block can be
130130
determined by scanning the entire text of the block for name binding operations.
131+
See :ref:`the FAQ entry on UnboundLocalError <faq-unboundlocalerror>`
132+
for examples.
131133

132134
If the :keyword:`global` statement occurs within a block, all uses of the names
133135
specified in the statement refer to the bindings of those names in the top-level

0 commit comments

Comments
 (0)