Ternary Operator in Python

Diez B. Roggisch deetsNOSPAM at web.de
Fri Apr 1 08:45:24 EST 2005


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