Created
March 20, 2021 10:50
-
-
Save animationdavid/fa5050f69457e7c93ad86125cb14d953 to your computer and use it in GitHub Desktop.
Python Switcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Switcher(object): | |
def numbers_of_options(self, argument): | |
"""Dispatch method""" | |
method_name = 'option_' + str(argument) | |
method = getattr(self, method_name, lambda: "Invalid option") | |
return method() | |
def option_1(self): | |
return "My option 1" | |
def option_2(self): | |
return "My option 2" | |
def option_3(self): | |
return "My option 3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment