Proposed PEP for a Conditional Expression

Michael Chermside mcherm at destiny.com
Fri Sep 14 16:36:39 EDT 2001


James_Althoff writes:
> With apologies for possibly having missed some parts of this thread . . .
> 
> Given:
> 1) nested scopes, and
> 2) recent proposals becoming more and more complicated and convoluted --
> e.g., embedding "break" and "return" statements inside if:else: expression
> syntax, highly overloaded meanings of if:else: ,
> inside/outside/upside/downside ordering of if:else: keywords, etc., . . .
> 
> Why not just start with something simple like a builtin "cond" function
> approximating the following:
> 
> 

James:

Now it's ME who's apologizing, for not reading YOUR post well enough.

I somehow overlooked the fact that you are passing FUNCTIONS not VALUES, 
through the use of lambda. Others have pointed out that the lambda 
functions can't make reference to variables in the current scope, but 
since that is FIXED! since the introduction of nested_scope, I'm 
disregarding it.

So your solution DOES work. I'll definitely add it to the PEP as another 
workaround... awkward, due to the need to type the lambdas, but 
certainly usable.

-- Michael Chermside

PS: thanks to EVERYONE who's been writing. I've only been RESPONDING to 
a small portion of the postings, but I've been gleaning LOTS of useful 
ideas, arguments, and phrasings to use for the PEP.





More information about the Python-list mailing list