diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-12-22 23:30:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-22 23:30:09 (GMT) |
commit | 86cdfaa885eedefe3a33fccc0bbccd0b6a388260 (patch) | |
tree | 93f1925691ea64af79c0f8e63039a4be35f2f370 | |
parent | de74d49b21f7671e2cbacf686e63efaee51959f5 (diff) | |
download | cpython-86cdfaa885eedefe3a33fccc0bbccd0b6a388260.zip cpython-86cdfaa885eedefe3a33fccc0bbccd0b6a388260.tar.gz cpython-86cdfaa885eedefe3a33fccc0bbccd0b6a388260.tar.bz2 |
gh-48496: Added example and link to faq for UnboundLocalError in reference (GH-93068)
(cherry picked from commit f3db68e6e66ebb36e1b9cb30daba913ecc736169)
Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
-rw-r--r-- | Doc/faq/programming.rst | 2 | ||||
-rw-r--r-- | Doc/reference/executionmodel.rst | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index f814048..bd75801 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -113,6 +113,8 @@ Yes. The coding style required for standard library modules is documented as Core Language ============= +.. _faq-unboundlocalerror: + Why am I getting an UnboundLocalError when the variable has a value? -------------------------------------------------------------------- diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst index d918356..081f71c 100644 --- a/Doc/reference/executionmodel.rst +++ b/Doc/reference/executionmodel.rst @@ -128,6 +128,8 @@ lead to errors when a name is used within a block before it is bound. This rule is subtle. Python lacks declarations and allows name binding operations to occur anywhere within a code block. The local variables of a code block can be determined by scanning the entire text of the block for name binding operations. +See :ref:`the FAQ entry on UnboundLocalError <faq-unboundlocalerror>` +for examples. If the :keyword:`global` statement occurs within a block, all uses of the names specified in the statement refer to the bindings of those names in the top-level |