Conditional operator in Python?

Tim Peters tim.one at home.com
Sat Mar 31 22:04:08 EST 2001


[Erik Max Francis]
> 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?

Eric, there's no feature from *any* language that isn't regularly suggested
for Python.  This one is regularly requested too, but is down in the noise.
Its most persistent proponent today is Eric Raymond, and you might want to
nag him to finish his long-threatened PEP on the topic.

In the meantime, try if/then/else <wink>.

hey-it-works-for-me-ly y'rs  - tim





More information about the Python-list mailing list