PEP-able? Expressional conditions

Paul Rubin http
Wed Sep 7 15:44:45 EDT 2005


Terry Hancock <hancock at anansispaceworks.com> writes:
> def ternary(condition, true_result, false_result):
> 	if condition:
> 		return true_result
> 	else:
> 		return false_result
> 
> Almost as good, and you don't have to talk curmudgeons into providing
> it for you.

Not the same at all.  It evaluates both the true and false results,
which may have side effects.



More information about the Python-list mailing list