Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def nasty(target):
- print(target, " is overrated. BAD!")
- def smart(target):
- print(target, " is a genius. SMART!")
- def dispatch_function(option1, f1, option2, f2):
- def func(option, value):
- #assert option == option1 or option == option2
- if option == option1:
- return f1(value)
- else:
- return f2(value)
- return func
- trump = dispatch_function('smart', smart, 'nasty', nasty)
- trump('smart', "FBI Director")
- trump('nasty', "Ford Motor")
Advertisement
Add Comment
Please, Sign In to add comment