Conditional operator in Python?
Emile van Sebille
emile at fenx.com
Sat Mar 31 21:13:08 EST 2001
Yes, it comes up. Generally, except for short-circuiting, the solutions
follow:
>>> 1 and 2 or 3
2
>>> 0 and 2 or 3
3
HTH,
--
Emile van Sebille
emile at fenx.com
---------
"Erik Max Francis" <max at alcyone.com> wrote in message
news:3AC68CB8.22AAF7B8 at alcyone.com...
> Okay, okay, but I still have to ask.
>
> Why isn't there a conditional operator (a ? b : c) in Python? 2.0 now
> has augmented assignments, and the FAQ even acknowledges that the
> conditional operator is sometimes quite convenient and gives some (very
> awkward) Python alternatives.
>
> I've been reading comp.lang.python for a while (since just before 2.0
> shipped) and I can't really remember much discussion about it. Is it a
> perennial request and I'm just missing it?
>
> --
> Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
> __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
> / \ I sidestep the either
> \__/ or choices of logic and choose both. | Ken Feit
> Product's Quake III Arena Tips / http://www.bosskey.net/
> Tips and tricks from the absolute beginner to the Arena Master.
More information about the Python-list
mailing list