How to create a custom string representation for a class object?

Consider this class:

class foo(object):
    pass

The default string representation looks something like this:

>>> str(foo)
"<class '__main__.foo'>"

How can I make this display a custom string?

5 Answers
5

Leave a Comment