Inline Conditionals?

Chris Dutton rubyguru at hotmail.com
Tue Aug 24 23:42:55 EDT 2004


Adonis wrote:
> How about something like:
> 
> 
>>>>def iif(condition, true=True, false=False):
> 
> ...     if condition:
> ...             return true
> ...     return false
> ...

Just a thought, but this would have unexpected results if used with 
function calls, if those function calls had side-effects, since both are 
evaluated, whereas the ternary operator in other languages only 
evaluates one of the possible expressions.



More information about the Python-list mailing list