New submission from jhpfjyne <jhpfj...@sharklasers.com>:

Accessing an attribute defined at class-level in the if clause of a list 
comprehension at class-level throws a NameError.

>>> class Foo:
...     a = ['a', 'b']
...     b = ['b', 'c']
...     c = [x for x in a if x not in b]
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in Foo
  File "<stdin>", line 4, in <listcomp>
NameError: name 'b' is not defined

----------
components: Interpreter Core
messages: 407002
nosy: jhpfjyne
priority: normal
severity: normal
status: open
title: NameError on if clause of class-level list comprehension
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45899>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to