Following this discussion, I tried to include _repr_pretty
in a mixin.
Without the mixin, it works as expected:
>>> class MyClass():
... def __repr__(self):
... return "The Repr."
... def __str__(self):
... return "The str."
... def _repr_pretty_(self, p, cycle):
... p.text(str(self) if not cycle else '...')
>>> my_object = MyClass()
>>> my_object
The str.
But if I move the _repr_pretty
into a mixin, it does not work anymore:
>>> class MyMixin:
... def _repr_pretty_(self, p, cycle):
... p.text(str(self) if not cycle else '...')
>>> class MyClass(MyMixin):
... def __repr__(self):
... return "The Repr."
... def __str__(self):
... return "The str."
>>> my_object = MyClass()
>>> my_object
The Repr.
Any ideas?