Created
October 27, 2011 12:00
-
-
Save href/1319371 to your computer and use it in GitHub Desktop.
Revisions
-
href revised this gist
Oct 28, 2011 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,13 @@ def convert(dictionary): return namedtuple('GenericDict', dictionary.keys())(**dictionary) """ >>> d = dictionary(a=1, b='b', c=[3]) >>> named = convert(d) >>> named.a == d.a True >>> named.b == d.b True >>> named.c == d.c True """ -
href revised this gist
Oct 28, 2011 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,12 @@ from collections import namedtuple def convert(dictionary): return namedtuple('GenericDict', dictionary.keys())(**dictionary) >>> d = dictionary(a=1, b='b', c=[3]) >>> named = convert(d) >>> named.a == d.a True >>> named.b == d.b True >>> named.c == d.c True -
href created this gist
Oct 27, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ namedtuple('GenericDict', dictionary.keys())(**dictionary)