Python : Revert to base __str__ behavior

python, string

Solution

You can use `object.__str__()`:

class A:
   def __str__(self):
      return "Something useless"

class B(A):
   def __str__(self):
      return object.__str__(self)

This gives you the default output for instances of `B`:

>>> b = B()
>>> str(b)
'<__main__.B instance at 0x7fb34c4f09e0>'

Problem

How can I revert back to the default function that python uses if there is no `__str__` method? ``` class A : def __str__(self) : return "Something useless" class B(A) : def __str__(self) : return some_magic_base_function(self) ```

Original source