Proposed PEP for a Conditional Expression

James_Althoff at i2.com James_Althoff at i2.com
Fri Sep 14 16:35:06 EDT 2001


Marcin Kowalczyk wrote:
>    abs = if x>=0 then x else -x
>or
>    abs = if x>=0: x else: -x
>looks more readable than
>    abs = cond(x>=0, lambda:x, lambda:-x)
>for me.

That's a fair opinion.  But you have to admit that the last one beats the
heck out of the first two in terms of implementation issues.

And is not nearly as humorous as
    abs = (x>=0 and [x] or [-x])[0]
as an available workaround.  ;-)

Jim





More information about the Python-list mailing list