On 12/5/2011 8:09 AM, Dave Angel wrote:

useful, such as if you print a list. The __str__() method of list calls
the __repr__() for each object inside it. So it can be useful to define
both, even if you decide to have them do the same thing.

If you want __str__ and __repr__ to do the same thing, you only need *one* def statement and an assignment.

    def __str__(self): <whatever>
    __repr__ = __str__

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to