An object wrapper for dict that allows for using object type notation with dictionaries.
pip install objdict-hephhay
An object style implementation for dict that allows for using object type dot(.) notation with dictionaries.
All dict operations such as .pop(), .items(), .contains() etc' will also work with ObjDict
from objdict_hephhay import ObjDict
object = ObjDict(<dict>)
object.<dict key>
dict : int Dictionary to convert
obj__depth : int depth of conversion to ObjDict
objdict.ObjDict An instance of ObjDict
>>> obj = ObjDict(foo = 1, bar = 2)
<ObjDict : {"foo" : 1, "bar" : 2}>
>>> dictionary = {"foo" : 1, "bar" : 2}
>>> obj1 = ObjDict(dictionary)
>>> obj1.foo
1
>>> dictionary_2 = {"foo" : 1, "bar" : 2, "baz" : {"alice" : 3, "bob" : {"steph" : 5}}}
>>> obj2 = ObjDict(dictionary_2, obj__depth = 1)
>>> obj2.bar
2
>>> obj2.baz
<ObjDict : {'alice': 3, 'bob': {'steph': 5}}>