Functions as object
switch = {
'one' : function1,
'two' : function2,
'three' : function3
}
try:
result = switch[choice]
except KeyError :
print 'I didn't understand your choice.'
else :
result ()
switch = {
'one' : function1,
'two' : function2,
'three' : function3
}
try:
result = switch[choice]
except KeyError :
print 'I didn't understand your choice.'
else :
result ()