Programming/Python | Posted by 알 수 없는 사용자 2008. 5. 11. 02:07

function dic

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 ()