Last active
September 25, 2018 22:06
-
-
Save whalesalad/135994edbf27479642170ddcc34f4c97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def handle_platypus(args): | |
pass | |
def handle_dog(args): | |
pass | |
def handle_cat(args): | |
pass | |
def fallback(args): | |
raise NoHandlerException() | |
def main(): | |
furry = check_for_furry() | |
has_flippers = check_for_flippers() | |
swimmer = can_it_swim() | |
lookup_table = { | |
# furry, has_flippers, swimmer | |
(True, True, True): handle_platypus, | |
(True, False, True): handle_dog, | |
(True, False, False): handle_cat | |
} | |
fn = lookup_table.get((furry, has_flippers, swimmer), fallback) | |
fn() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment