Methods for Python classes representation
I know that methods __repr__ and __str__ exist to give a formal and informal representation of class instances. But does an equivalent exist for class objects too, so that when the class object is printed, a nice representation of it could be shown? >>> class Foo: ... def __str__(self): ... return "instance of class Foo" ... >>> foo = Foo() >>> print foo instance of class Foo >>> print Foo __main__.Foo unutbu When you call print(foo) , foo 's __str__ method is called. __str__ is found in the class of foo , which is Foo . Similarly, when you call print(Foo) , Foo 's __str__ method is called. _