Last active
March 11, 2021 20:53
-
-
Save Hultner/8eb45817c6ecfd3ed3bcf834838e913e to your computer and use it in GitHub Desktop.
Pattern matching HTTP Status codes
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
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