Created
May 26, 2013 23:54
-
-
Save klenwell/5654486 to your computer and use it in GitHub Desktop.
Converts Python dict to object so that d['some_key'] can be accessed at d.some_key
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
# -*- coding: utf-8 -*- | |
""" | |
DictObject | |
Converts dict to object | |
""" | |
from collections import defaultdict | |
class DictObject(defaultdict): | |
def __getattr__(self, key): | |
return self[key] | |
def __setattr__(self, key, val): | |
self[key]=val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment