(no subject)

Roman Suzi rnd at onego.ru
Mon Feb 17 02:32:50 EST 2003


On Sun, 16 Feb 2003, John D. wrote:

> 
> Is there any way to do bool?case0:case1 like in C?
> but in Python?

No special ternary operator in Python. However:

In cases where case0 is guaranteed True:

bool and case0 or case1

For example, 

x < y and "less" or "more"

(nonempty string value is True in Pyhton)


It's a FAQuestion:

http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.016.htp

...and hotly debutted topic in c.l.py these days.

 
> John

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 







More information about the Python-list mailing list