On Tue, Apr 17, 2018 at 6:20 PM, Steven D'Aprano <steve@pearwood.info> wrote:
If there are tests which intentionally verify this behaviour, that
really hurts your position that the behaviour is an accident of
implementation. It sounds like the behaviour is intended and required.

​It is nonetheless bizarre and unexpected behavior.

>>> prefix = 'global'
>>> [prefix+c for c in 'abc']
['globala', 'globalb', 'globalc']

>>> def func():
...     prefix = 'local'
...     print([prefix+c for c in 'abc'])
>>> func()
['locala', 'localb', 'localc']

>>> class klass:
...     prefix = 'classy'
...     items = [prefix+c for c in 'abc']
>>> print(klass.items)
['globala', 'globalb', 'globalc']

In Python 2, that last one would produce 'classya' and friends, due to the "broken" comprehension scope.