Proposal: function which simulates C ?: operator

Erik Max Francis max at alcyone.com
Sun Jul 11 22:54:53 CEST 2004


Tor Iver Wilhelmsen wrote:

> Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:
> 
> >   (lambda: g(x), lambda: f(x))[bool(condition)]()
> 
> Since you call the object afterwards, you don't need the lambdas
> (which add a layer of indirection), just the function references:
> 
> (g, f)[bool(condition)]()

Well, you meant:

	(g, f)[bool(condition)](x)

but that was taking his example too literally; he was just using f(x)
and g(x) to expressions that you wanted laziy evaluated.

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Forever we / Infinitely
    -- Sandra St. Victor



More information about the Python-list mailing list