bug? __repr__ vs. __str__

Bruce Edge bedge at troikanetworks.com
Fri Apr 20 18:43:10 EDT 2001


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.



More information about the Python-list mailing list