PEP 308: A PEP Writer's Experience - PRO

Evan evan at 4-am.com
Sun Feb 9 19:48:59 CET 2003


Alex Martelli wrote:
>>Samuele> z = ife(cond and [x] or [y])

>>        ife = list.pop

def iif(r):
     if r: return r[0]

def then(r): return (r,)

 >>> for a in (1,2,3):
...     print iif(a == 1 and then(1)),
...     print iif(a == 1 and then(1) or then(2)),
...     print iif(a == 1 and then(1) or a == 2 and then(2))
...
1 1 1
None 2 2
None 2 None

Cute?

Cheers,

Evan @ 4-am





More information about the Python-list mailing list