Created
August 4, 2017 13:03
-
-
Save MattWoodhead/0ccec28f1db57afd2935eed879f26557 to your computer and use it in GitHub Desktop.
One-liner to convert a Dictionary to a frozen named tuple
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 | |
test_dict = {"a": 0, | |
"b": 1, | |
"c": 2, | |
"d": 3, | |
} | |
test = namedtuple("test", test_dict.keys())(**test_dict) | |
print(test.a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment