Ternary Operator in Python

gene.tani at gmail.com gene.tani at gmail.com
Fri Apr 1 20:36:44 EST 2005


The good ol' DiveInto says:

http://diveintopython.org/power_of_introspection/and_or.html#d0e9975

http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52310

Diez B. Roggisch wrote:
> praba kar wrote:
>
> > Dear All,
> >     I am new to Python.  I want to know how to
> > work with ternary operator in Python.  I cannot
> > find any ternary operator in Python.  So Kindly
> > clear my doubt regarding this
>
> There is no ternary operator in python. There are several idioms that
can be
> used to emulate one to a certain degree - but they are scolwed on by
quite
> a few people. So better to not use them and just do it in a if: else:
> clause. 
> 
> -- 
> Regards,
> 
> Diez B. Roggisch




More information about the Python-list mailing list