Equivalent to (a ? b : c) ?

Justin Sheehy dworkin at ccs.neu.edu
Mon Dec 20 16:48:53 EST 1999


"Jesper Hertel" <jh at cddk.dk> writes:

> > ((a and (b,)) or (c,))[0]

> I hope this was a joke. That kind of constructions is impossible to read for
> other programmers, making the program hard to maintain.
> 
> I like maxm's function much better, because you can easily understand what
> the meaning is.

Sure, maxm's function is much nicer-looking and easier to read.  But
the above snippet has the same effect as C's ternary operator, while
the function does not.

-Justin

 



More information about the Python-list mailing list