Proposed PEP for a Conditional Expression

James_Althoff at i2.com James_Althoff at i2.com
Thu Sep 20 13:58:07 EDT 2001


Tom Payne wrote:
>To me,
>
>          count = 1 if by_land() else
>                  2 if by_sea()  else
>                  0
>
>is clearer than
>
>         if by_land():
>                 count = 1
>         elif by_sea():
>                 count = 2
>         else:
>                 count = 0

On the other hand, it's hard to make the case that the latter is *unclear*.
And it's already there, just waiting to be used. ;-)

Jim





More information about the Python-list mailing list