Created
January 17, 2016 04:51
-
-
Save atmb4u/2028e03eed47bedfa637 to your computer and use it in GitHub Desktop.
converting dictionary to class
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 characters
class Data: | |
def __init__(self, dictionary): | |
for k, v in dictionary.items(): | |
setattr(self, k, v) | |
o = Data({'a': 1, 'b': 2}) | |
o.a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment