Diez B. Roggisch wrote:
Yep. And it's easy enough if you don't care about them being different..

def __repr__(self):
    return str(self)

If I ever wanted __str__ and __repr__ to return the same thing, I would make them equal:

def __str__(self):
    return 'whatever you want'
__repr__ = __str__

That makes it more obvious to me what's going on. As a bonus, it saves one method call for every repr call.

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

Reply via email to