Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mtreacy002/d8f9a9778792fe111ea2a70671de5f1b to your computer and use it in GitHub Desktop.
Save mtreacy002/d8f9a9778792fe111ea2a70671de5f1b to your computer and use it in GitHub Desktop.
Python decorator - tuple to namedtuple
def http_response_checker(result):
if result[1] == HTTPStatus.NOT_FOUND:
result = http_not_found_status_checker(result)
# ... more 'if' here ...
return result
def http_not_found_status_checker(result):
if result[0] == messages.WRONG_USERNAME_OR_PASSWORD
return messages.WRONG_USERNAME_OR_PASSWORD, HTTPStatus.UNAUTHORIZED
# ... more 'if' here ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment