bug? __repr__ vs. __str__

gzeljko gzeljko at sezampro.yu
Fri Apr 20 19:41:43 EDT 2001


It was explained here a month ago.
Search archives.

ly-y'rs-gzeljko


Bruce Edge <bedge at troikanetworks.com> wrote in message
news:20010420.154310.1501252996.615 at mead.troikanetworks.com...
> Does this seem broken to anyone else?
>
> >>> class T:
> ...   def __repr__(self):
> ...     return "repr"
> ...   def __str__(self):
> ...     return "str"
> ...
>
> >>> t =T()
> >>> str(t)
> 'str'
>
> >>> l=[t,t,t,t]
> >>> str(l)
> '[repr, repr, repr, repr]'
>
> I would have expected:
> '[str, str, str, str]'
>
> -Bruce.
> --
> http://mail.python.org/mailman/listinfo/python-list
>









More information about the Python-list mailing list