You should use __repr__()
:
>>> class Foo():
... def __repr__(self):
... return "I'm Foo"
...
>>> foo = Foo()
>>> foo
I'm Foo
Also see:
- Representing your Classes from "A Guide to Python's Magic Methods"
- Difference between __str__ and __repr__ in Python
- Understanding repr( ) function in Python
Hope that helps.