[Python-Dev] Conditional expressions and sequences
Skip Montanaro
skip@pobox.com (Skip Montanaro)
Tue, 16 Oct 2001 11:04:51 -0500
Paul> Now in your new syntax this is essentially
Paul> x = if condition then t else f
Paul> Therefore it would be cool if the implementation was
Paul> x=condition.__where__(t,f). This slot could be overwritten by
Paul> classes like Numeric's array. If condition was a list this might
Paul> be useful too.
Unfortunately, that requires both t and f to be evaluated. In a NumPy
setting that's probably not a big deal because in most cases both values
will be used in the resulting output. In a scalar context, the
short-circuit nature of the expression is often important. If implemented
as any kind of function you've lost that capability.
--
Skip Montanaro (skip@pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/