summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-18 16:42:57 (GMT)
committerGeorg Brandl <georg@python.org>2008-01-18 16:42:57 (GMT)
commita9e073d100c3869231ce7275ff7a810d8db74fc4 (patch)
tree048a6f66306d4cbdf3d01910750688eabbd5e378 /Doc/reference
parenta26c73ed5542173f30fc92a5892de11f70c2b546 (diff)
downloadcpython-a9e073d100c3869231ce7275ff7a810d8db74fc4.zip
cpython-a9e073d100c3869231ce7275ff7a810d8db74fc4.tar.gz
cpython-a9e073d100c3869231ce7275ff7a810d8db74fc4.tar.bz2
Note that genexps are function scopes too and therefore won't see class attributes.
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/executionmodel.rst8
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst
index 69a6259..c5a24e9 100644
--- a/Doc/reference/executionmodel.rst
+++ b/Doc/reference/executionmodel.rst
@@ -52,7 +52,13 @@ variable is defined in a block, its scope includes that block. If the
definition occurs in a function block, the scope extends to any blocks contained
within the defining one, unless a contained block introduces a different binding
for the name. The scope of names defined in a class block is limited to the
-class block; it does not extend to the code blocks of methods.
+class block; it does not extend to the code blocks of methods -- this includes
+generator expressions since they are implemented using a function scope. This
+means that the following will fail::
+
+ class A:
+ a = 42
+ b = list(a + i for i in range(10))
.. index:: single: environment