[Python-3000] Removing repr
Edward Loper
edloper at gradient.cis.upenn.edu
Fri Apr 7 02:56:04 CEST 2006
Greg Ewing wrote:
> The guideline I use is quite different: str() is for
> normal program output, repr() is for debugging
> output.
I think that another important difference between str() and repr() is
that repr() is often used as an embedded string in other objects'
representations; but str() usually is not. Thus, the string returned by
repr() should not span multiple lines, and it should be easy to match up
its beginning with its end. str() doesn't have these restrictions.
So actually, it can sometimes be convenient to use both for debugging
purposes, with repr() for a short string, suitable for embedding, and
str() for a more verbose, multiline, formatted string.
(Another -1 for combining them.)
-Edward
More information about the Python-3000
mailing list