Mailing List Archive

[issue5106] Update Naming & Binding statement for 3.0
New submission from Terry J. Reedy <tjreedy@udel.edu>:

Language / Execution Model / Naming & Binding
just before example that does not work,

class A:
a = 42
b = list(a + i for i in range(10))

says :
"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 – this includes
generator expressions since they are implemented using a function scope."

As pointed out by Alan Isaacs (clp), in 3.0,
"this includes comprehensions and generator expressions"
would be more complete and not possibly imply that g.e.s are special in
this regard. In 2.x,
c = [a + i for i in range(10)]
works but it fails with same
"NameError: global name 'a' is not defined"
in 3.0. In fact, I think 'comprehensions and ' should be added just
because this is a change which people could trip over.

----------
assignee: georg.brandl
components: Documentation
messages: 80810
nosy: georg.brandl, tjreedy
severity: normal
status: open
title: Update Naming & Binding statement for 3.0
versions: Python 3.0, Python 3.1

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5106>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5106] Update Naming & Binding statement for 3.0 [ In reply to ]
Benjamin Peterson <benjamin@python.org> added the comment:

Fixed in r69132.

----------
nosy: +benjamin.peterson
resolution: -> fixed
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5106>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com