PEP 308: A PEP Writer's Experience - PRO

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Sun Feb 9 15:10:50 EST 2003


Andrew Koenig <ark at research.att.com> writes:
> Samuele> ife = lambda box: box[0]
> Samuele> z = ife(cond and [x] or [y])
> 
> Samuele> if Python had had a ternary cond op, I would never have seen
> Samuele> that <sniff>.
> 
> You're right -- that's about the nicest workaround I've seen.

I'm missing something--x and y both get evaluated in that example,
so it's only a partial work around?




More information about the Python-list mailing list