Created
July 6, 2020 02:07
-
-
Save mtreacy002/45be981b9f09034f2ce3f63543a75399 to your computer and use it in GitHub Desktop.
Python decorator - tuple to namedtuple
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
from collections import namedtuple | |
def http_response_namedtuple_converter(user_function): | |
def tuple_to_namedtuple_http_response(result): | |
HttpNamedTupleResponse = namedtuple("HttpNamedTupleResponse", ["message", "status_code"]) | |
converted_result = HttpNamedTupleResponse(*result) | |
return user_function(converted_result) | |
return tuple_to_namedtuple_http_response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment