⬅︎ Back to SmartDict - a smart 'dict' wrapper
another implementation, but allows more than one mapping in the creator, also less restrictive with what it can be updated from:class SmartDict(dict):....def __init__(self, *a, **kw):........super(SmartDict, self).__init__(**kw)........for x in a:............try:................self.update(x)............except TypeError:................self.update(x.__dict__)........self.__dict__ = self
Comment
another implementation, but allows more than one mapping in the creator, also less restrictive with what it can be updated from:
class SmartDict(dict):
....def __init__(self, *a, **kw):
........super(SmartDict, self).__init__(**kw)
........for x in a:
............try:
................self.update(x)
............except TypeError:
................self.update(x.__dict__)
........self.__dict__ = self