stumbled on python iif() equivalent, at last

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sat Jun 23 11:54:41 EDT 2001


Sat, 23 Jun 2001 17:42:22 +0200, Laurent Szyster <laurent.szyster at q-survey.be> pisze:

> so, there's an iif (condition, is_true, is_false) python equivalent:
> 
>     >>> 1 and 'c' or 'o'
>     'c'
>     >>> 0 and 'c' or 'o'
>     'c'

It works correctly only if 'c' is true.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list