python-frozendict
python-frozendict copied to clipboard
Repr implementation should eval
All builtin types have a __repr__
implementation that can be fed to eval
to obtain the original Python value. This is on purpose. frozendict
and OrderedFrozendict
simply being an immutable version of builtin types should also support this behavior. One simply need to slightly modify the __repr__
implementation.
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self._dict)
This parallels frozenset
's __repr__
.
eval is evil...
@Marco-Sulla agree, but sometimes it can be handy, not sure about this case though.