Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3.0
- def switch(value, d):
- try:
- d[value]()
- except KeyError:
- d["default"]()
- def my_switch(value):
- switch(value, {
- 1 : (lambda: print("hello")),
- 2 : (lambda: print("goodbye")),
- "default" : (lambda: print("default"))
- })
- my_switch(1)
- my_switch(2)
- my_switch(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement