Skip to content

Instantly share code, notes, and snippets.

@MattWoodhead
Created August 4, 2017 13:03
Show Gist options
  • Save MattWoodhead/0ccec28f1db57afd2935eed879f26557 to your computer and use it in GitHub Desktop.
Save MattWoodhead/0ccec28f1db57afd2935eed879f26557 to your computer and use it in GitHub Desktop.
One-liner to convert a Dictionary to a frozen named tuple
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