printing list, is this a bug?

Dan Bishop danb_83 at yahoo.com
Sat May 26 14:30:56 EDT 2007


On May 25, 3:55 pm, William Chang <mr.williamch... at gmail.com> wrote:
> Is the different behavior between __repr__ and __str__ intentional
> when it comes to printing lists? Basically I want to print out a list
> with elements of my own class, but when I overwrite __str__, __str__
> doesn't get called but if I overwrite __repr__, __repr__ will get
> called. Is this a bug?
> ...

As has been mentioned, this was a deliberate design decision.  Partly
to make things like str(['a', 'b, c']) less confusing.




More information about the Python-list mailing list