]> granicus.if.org Git - python/commitdiff
Note that genexps are function scopes too and therefore won't see class attributes.
authorGeorg Brandl <georg@python.org>
Fri, 18 Jan 2008 16:42:57 +0000 (16:42 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 18 Jan 2008 16:42:57 +0000 (16:42 +0000)
Doc/reference/executionmodel.rst

index 69a6259a235e75f2612f5b63a5cbab572aadb7e3..c5a24e9ca0f2114537127ebdadc3f21dab834331 100644 (file)
@@ -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