[Python-Dev] str(container) should call str(item), not repr(item)
skip at pobox.com
skip at pobox.com
Mon Jul 28 10:59:42 CEST 2008
Ondrej> i.e. the str on list (and tuple and dict) calls repr() on the
Ondrej> elements, instead of str. This really seems to me like a bug.
Ondrej> Because if I wanted the repr() representation, I'd call repr()
Ondrej> on the list/tuple/dict. If I want a nice readable
Ondrej> representation, I call str(). That's the philosophy, no?
I think this is the case which calls for the distinction:
>>> str(["1", "2", "3"])
"['1', '2', '3']"
>>> str([1, 2, 3])
'[1, 2, 3]'
If the first case did as you suggested you couldn't distinguish it from the
second.
Skip
More information about the Python-Dev
mailing list