from abc import ABCMeta from enum import Enum class HumanReadableEnum(Enum): def __str__(self): return self._name_ def __repr__(self): return self._name_ class HumanReadableABCMeta(ABCMeta): def __str__(cls): if "__repr_name__" in cls.__dict__: return cls.__dict__["__repr_name__"] return cls.__name__ def __repr__(cls): if "__repr_name__" in cls.__dict__: return cls.__dict__["__repr_name__"] return cls.__name__ class HumanReadableABC(metaclass=HumanReadableABCMeta): @classmethod def __str__(cls): if "__repr_name__" in cls.__dict__: return cls.__dict__["__repr_name__"] return type(cls).__name__ @classmethod def __repr__(cls): if "__repr_name__" in cls.__dict__: return cls.__dict__["__repr_name__"] return type(cls).__name__