[Python-de] (no subject)

Dinu Gherman gherman at darwin.in-berlin.de
Wed Oct 9 15:14:33 EDT 2002


Dinu Gherman:

> lambda x: {None:10, 1:20}.get(x, 10)

Oder:

   lambda x: ((x is None) and 10) or ((x == 1) and 20) or 10

was in dem Fall identisch ist mit:

   lambda x: ((x == 1) and 20) or 10

Klarer und eleganter geht's nimmer! ;-)

Dinu

--
Dinu C. Gherman
......................................................................
"Political satire became obsolete when Henry Kissinger was awarded
the Nobel Peace Prize." (Tom Lehrer)





More information about the Python-de mailing list