Skip to content

Instantly share code, notes, and snippets.

@Hultner
Last active March 11, 2021 20:53
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 Hultner/8eb45817c6ecfd3ed3bcf834838e913e to your computer and use it in GitHub Desktop.
Save Hultner/8eb45817c6ecfd3ed3bcf834838e913e to your computer and use it in GitHub Desktop.
Pattern matching HTTP Status codes
status_code = 200
match status_code:
case 404: print("Not found")
case 200: print("Ok")
case _: raise ValueError("Can't handle status code")
# Prints "Ok"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment