O'Reilly logo
  • You Wang thinks this is interesting:

Technically, __str__ is preferred by print and str, and __repr__ is used as a fallback for these roles and in all other contexts.

From

Cover of Learning Python, 5th Edition

Note

print(a) Class My is a custom class (str) a Out[6]: Class My is a custom class (repr)