Good or bad use of __repr__?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Feb 4 06:29:01 CET 2009


On Wed, 04 Feb 2009 05:18:29 +0000, Steven D'Aprano wrote:

> ... I'd recommend:
> 
>     def __repr__(self):
>         return '%s(%s, %s)' % (
>         self.__class__.__name__, self.ptr, self.name)
>     def __str__(self):
>         return "<dim=%g>" % self.size
> 
> 
> except of course your class doesn't store ptr.

Ah crap, sorry, I meant setp not ptr. Sorry for the confusion.



-- 
Steven



More information about the Python-list mailing list