Skip to content Skip to sidebar Skip to footer

Default __str__ Method For An Instance

I have a class without a str or repr method. And when I call it: >>> from ingest.tpr import TPR >>> t=TPR() >>> t # that is, 'repr(t)'

Solution 1:

t.__repr__ (which is what repr(t) calls) resolves to (assuming no other upstream definitions) object.__repr__, which is defined by the Python implementation (for example, https://github.com/python/cpython/blob/master/Objects/typeobject.c#L3827)


Post a Comment for "Default __str__ Method For An Instance"