Open fabiocaccamo opened 2 years ago
Hello, is it possible to add an attribute to a benedict? I wanted to add an is_frozen
attribute, but I encountered an error like this:
raise AttributeError(attr_message) from None
AttributeError: 'benedict' object has no attribute 'is_frozen'
I've written:
class benedict(KeyattrDict, KeypathDict, IODict, ParseDict):
def __init__(self, *args, **kwargs):
....
self.is_frozen = False
def freeze(self):
self.is_frozen = True
def __setitem__(self, key, value):
if self.is_frozen:
raise TypeError("This dictionary is immutable")
return super().__setitem__(key, self._cast(value))