[Python-Dev] str(container) should call str(item), not repr(item) (original) (raw)

Sebastian Haase haase at msg.ucsf.edu
Mon Jul 28 12:04:21 CEST 2008


On Mon, Jul 28, 2008 at 10:59 AM, <skip at pobox.com> wrote:

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. Look at this -- it seems to me that it should work fine.... ---- Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)

str("qwer") 'qwer' repr("qwer") "'qwer'"



More information about the Python-Dev mailing list