There is no __dict__ attribute on an object that inherits from Munch
bobh66 opened this issue · 4 comments
If I define an object that inherits from Munch:
class Foo(Munch):
def init(self, bar):
self.bar = bar
and then do:
myfoo = Foo("mybar")
the resulting myfoo object has no dict attribute, so while I can do myfoo.toDict(), I can't do myfoo.dict which would be nice to allow it to be treated like any other object.
@Property
def dict(self):
return self.toDict()
would allow myfoo.dict to work the same way as toDict()
@vmalloc is there any issue with this approach? If possible I would like to have this merged and published soon.
The PR referred to does not add dict
method as described in this issue, but it does supplants the dict property with self.toDict()
and it enabled using vars(munch)
to get the dictionary.
This solves #21
@episodeyang The approach is fine - it just took me some time to get to it because I was swamped with other things. Thanks a lot for contributing!