Created
May 19, 2017 15:20
-
-
Save zeffii/b63f3cc61f26109a8e50a732808186ba to your computer and use it in GitHub Desktop.
dict_to_namedtuple.py
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 | |
# one level named tuple | |
def dict_to_namedtuple(kwargs): | |
nt = namedtuple('props', kwargs.keys()) | |
for field in nt._fields: | |
setattr(nt, field, kwargs[field]) | |
return nt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and