Proposed new syntax

Chris Angelico rosuav at gmail.com
Thu Aug 10 10:45:19 EDT 2017


On Fri, Aug 11, 2017 at 12:28 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> How about these?
>
> [x + y for x in (0, 1, 2, 999, 3, 4) while x < 5 for y in (100, 200)]
>
> [x + y for x in (0, 1, 2, 999, 3, 4) if x < 5 for y in (100, 200)]
>

I know exactly what the current syntax does, and yet I fell into an
automatic mental trap of expecting (100, 200) to be a range. So
"intuitiveness" is not necessarily reliable.

ChrisA



More information about the Python-list mailing list