[New-bugs-announce] [issue26951] Unintuitive error when using generator expression in class property
Corey Farwell
report at bugs.python.org
Wed May 4 10:34:33 EDT 2016
New submission from Corey Farwell:
```
class A:
B = range(10)
C = frozenset([4, 5, 6])
D = list(i for i in B)
E = list(i for i in B if i in C)
```
```
coreyf at frewbook-pro /tmp [1]> python3 a.py
Traceback (most recent call last):
File "a.py", line 1, in <module>
class A:
File "a.py", line 5, in A
E = list(i for i in B if i in C)
File "a.py", line 5, in <genexpr>
E = list(i for i in B if i in C)
NameError: name 'C' is not defined
```
Why should I be able to access B but not C?
----------
components: Interpreter Core
messages: 264819
nosy: corey
priority: normal
severity: normal
status: open
title: Unintuitive error when using generator expression in class property
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26951>
_______________________________________
More information about the New-bugs-announce
mailing list