[Python-3000] Removing repr

Guido van Rossum guido at python.org
Thu Apr 6 20:09:29 CEST 2006


You are all correct. :-)

The way I think of it is that str() is used by print; repr() is used
by the interactive prompt. Clearly you want print 'abc' to print abc
without quotes; but in the interactive prompt you want different
output for the number 1 and the string '1', and that's what repr() is
for.

FWIW, for types that implement them the same, I'd like to see them
return something from which the type is obvious, i.e. repr()-like.
Just yesterday I helped someone debug an AttributeError where he was
convinced that an object was a string because its repr() looked like a
string; but it was a dbapi DateTime object (don't recall which
implementation).

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list