Python Pseudo-Switch
James Stroud
jstroud at mbi.ucla.edu
Sat May 7 20:36:39 EDT 2005
Hello All,
Because of my poorly designing a database, I have recently found it necessary
to explore the wonders of the Python pseudo-switch:
do_case = { "A" : lambda x: x["bob"],
"B" : lambda x: x["carol"],
"C" : lambda x: "Ted",
"D" : lambda x: do_something(x) }
my_thing = do_case[get_value_from_thin_air()](adict)
How to handle this kind of thing when lambda is removed from the language,
beside the obvious def'ing those tiny little functions?
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/
More information about the Python-list
mailing list