[Python-3000] UPDATED: PEP 3138- String representation in Python 3000

Greg Ewing greg.ewing at canterbury.ac.nz
Wed May 28 04:41:55 CEST 2008


Jim Jewett wrote:
> Again, what is the advantage of having str(x) be redundant to repr(x)
> in the case of containers?

I think you're misrepresenting the situation when you
describe it that way.

Guido didn't sit down and think "I know, let's make
str(lst) do the same as repr(lst)." He thought
"It's not clear what str(lst) should do, so let's
not define it at all."

There can't be a bug in list.__str__, because
list.__str__ *does not exist*. If you want one, you
have to decide what you want it to do and write it
yourself.

I've never found this to be a problem. Either
repr(lst) is good enough, or I've wanted something
completely different and had to write my own code
for it anyway.

I've *never* wanted anything that was just like
repr(lst) except that it didn't quote the strings.
That would only be confusing.

-- 
Greg


More information about the Python-3000 mailing list