> That's not the point of this check. The point of this check is that on
> Python 2, the binding to x in the comprehension bleeds outside of the
> comprehension scope

Got it.

Still, this code:

>     x = 10
>     [x for x in range(3)]
>     print(x + 1)

will run differently in Python 2 than Python3, so even if that was a
conscious choice by the author, a --py3k flag should cause a message
for this code. This is even worse than the simpler

>     [x for x in range(3)]
>     print(x + 1)

because at least that will raise a NameError when run in Python 3. The
three-line construct will still run, though produce different output.

Skip
_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality

Reply via email to