Proposed new syntax

Ian Kelly ian.g.kelly at gmail.com
Fri Aug 11 10:39:52 EDT 2017


On Fri, Aug 11, 2017 at 6:53 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> 10.08.17 23:28, Ian Kelly пише:
>>
>> So, perhaps a better syntax could be:
>>
>> [x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5 else break]
>
>
>     (0, 1, 2, 999, 3, 4) if x < 5 else break
>
> looks too similar to the ternary operator.

It is entirely intentional and a point in its favor, in my view, that
"x + 1 ... if x < 5 else break" resembles the ternary operator, as it
basically is a special syntax of that. But I take your point that it
also resembles the ternary in "(0, 1, 2, 999, 3, 4) if x < 5 else
break", which could lead to some confusion.



More information about the Python-list mailing list