Skip to content

Instantly share code, notes, and snippets.

@whalesalad
Last active September 25, 2018 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whalesalad/135994edbf27479642170ddcc34f4c97 to your computer and use it in GitHub Desktop.
Save whalesalad/135994edbf27479642170ddcc34f4c97 to your computer and use it in GitHub Desktop.
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