PEP-able? Expressional conditions

Terry Hancock hancock at anansispaceworks.com
Wed Sep 7 16:11:21 CEST 2005


On Wednesday 07 September 2005 05:29 am, Kay Schluehr wrote:
> Instead of pushing statements into expressions one can try to do it the
> other way round and model expressions with the functionality of
> statements. 

> Alternative syntax proposals:
> 
> (a)   (COND1,EXPR1) || (COND2,EXPR2)
> (b)   (COND1,EXPR1) case (COND2,EXPR2)
> (c)   (COND1,EXPR1) owise (COND2,EXPR2)
> (d)   (COND1,EXPR1) ? (COND2,EXPR2) 

You appear to be reinventing the C "ternary operator".  This is
definitely a dead horse. There was already a PEP, and it was
refused.

If you actually want this, you're going to have to implement it
with a function:

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.

Cheers,
Terry		

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com




More information about the Python-list mailing list