__str__ vs. __repr__
tino at wildenhain.de
Mon Nov 1 21:50:22 CET 1999
Randall Hopper wrote:
> 1) Is there a convention for what __str__ and __repr__ should return for
> 2) Or, whatever they return, should they return the same value?
> 3) If so, why have both in the language?
> Searching the archives yields an example with odd behavior that
> suggests they should generally return the same value:
If you test, its oviously (I thin its mentioned somewhere in the docs
__str__ represents an human-readable version of the object as string for
with "print" or formatet string ("%s")
__repr__ should produce a form that can be cut & pasted to construct the
see the difference?
More information about the Python-list