Conditional operator in Python?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Sep 4 07:25:48 EDT 2001


Tue, 04 Sep 2001 12:57:55 +0200, Weet Vanniks <Weet.Vanniks at el_simpatico.be> pisze:

> I would never use:
>     whatever = cond_choose(cond, format_disk(), leave_it_as_is())
> for the mere reason that I have been taught that:
>     1. when there is room for confusion, people get confused
>     2. arguments in a function call should NEVER have side-effects.

And since alternatives of a functional if can have side effects,
it follows that if should not be expressed as a function call.

Currently there is no better alternative than split the computation
into multiple statements with temporary variables.
(cond and [a] or [b])[0] is too ugly.

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



More information about the Python-list mailing list