PEP 308: A PEP Writer's Experience - PRO
Andrew Koenig
ark at research.att.com
Sun Feb 9 11:38:12 EST 2003
Samuele> As you might know the "cutest" (my take) general solution to
Samuele> the problem in current Python (performance aside), has been
Samuele> posted by Gerald S. Williams to python-dev:
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.
But I think I can improve it a tiny bit:
ife = list.pop
Shorter and faster, yes?
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list