__str__ vs. __repr__

Ivan Frohne frohne at gci.net
Sun Nov 7 23:15:28 CET 1999


Toby Dickenson <htrd90 at zepler.org> wrote in message
news:u4glOIWXzGrqvJnI+IlPAQeurz1J at 4ax.com...
> >repr(obj) should return a string such that
> >    eval(repr(obj)) == obj
>
> I don't understand the motivation for this requirement. Why would
> anyone want to pass such a string to eval? If you anticipate the need
> for reconstructing the object from a textual representation, then
> surely pickle is a better option?

Some objects can't be pickled.  Arrays, for example.

--Ivan Frohne







More information about the Python-list mailing list