Proposal: function which simulates C ?: operator

Tor Iver Wilhelmsen tor.iver.wilhelmsen at
Sun Jul 11 22:48:05 CEST 2004

Paul Rubin <> 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)]()

More information about the Python-list mailing list