Sign In
|
Register
Please Log In to save to favorites
TAGs
python, switch, case
Versions
Versions
30/12/2009 21:46:34
Switch equivalent statement in python
by
duniyadnd
Switch statement in Python - taken from
http://simonwillison.net/2004/May/7/switch/
1.
result = {
2.
'a': lambda x: x * 5,
3.
'b': lambda x: x + 7,
4.
'c': lambda x: x - 2
5.
}[value](x)
Comments
Sign in to give your comments.