something like "if" that returns a value?
David Brown
david at no.westcontrol.spam.com
Mon Nov 11 07:01:39 EST 2002
"Paul Rudin" <Paul_Rudin at scientia.com> wrote in message
news:ur8dss7w6.fsf at scientia.com...
> >>>>> "AM" == Alex Martelli <aleax at aleax.it> writes:
>
> AM> Paul Rudin wrote:
> >> .... lisp's if:
> >>
> >> (if x y z)
> >>
> >> which returns y if x is true and z otherwise.
> >>
> >> ... is there a succinct way of expressing this in the base language?
>
> [snip urls]
>
> Thanks for the reply.
>
> Seems like the executive summary is : "No" :-)
>
There are ways to do it, but it's a matter of how general a solution you
want, and whether it would be better to express the code in other ways.
However, you might try:
(y, z)[not x]
I think that will give the required result in most cases, but at a definite
cost in readability.
More information about the Python-list
mailing list