Abstract and concrete syntax

Terry Reedy tjreedy at udel.edu
Fri Jun 10 13:29:02 EDT 2005


"Kay Schluehr" <kay.schluehr at gmx.net> wrote in message 
news:1118411839.922816.94730 at g43g2000cwa.googlegroups.com...
> Mandus schrieb:
>> You can do stuff like this: lambda x: x and 2 or 3

This is limited by the requirement (often met) that bool(true-branch) == 
True

> You can also do this
>
>   lambda x: {True:2,False:3}.get(bool(a))

This is limited by the requirement that both branches be computable 
regardless of the value of the condition.

> which is both beautiful and pythonic.

Beauty is in the eye of the beholder.  It seems that relative pythonicity 
sometimes is also ;-).

Terry J. Reedy






More information about the Python-list mailing list