RosettaCodeData/Task/Conditional-structures/Python/conditional-structures-6.py

9 lines
131 B
Python
Raw Normal View History

2013-10-27 22:24:23 +00:00
# The above, but with a dict literal
dispatcher = {
0: foo,
1: bar,
2: baz,
}
# ...
results = dispatcher.get(x, boz)()