PEP-able? Expressional conditions

Bengt Richter bokr at oz.net
Thu Sep 8 04:37:14 EDT 2005


On Wed, 7 Sep 2005 17:53:46 -0500, Terry Hancock <hancock at anansispaceworks.com> wrote:

>On Wednesday 07 September 2005 02:44 pm, Paul Rubin wrote:
>> 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.
>
>If you are depending on that kind of nit-picking behavior,
>you have a serious design flaw, a bug waiting to bite you,
>and code which shouldn't have been embedded in an expression
>in the first place.
>
Or you might know excatly what you are doing ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list