Dealing with the __str__ method in classes with lots of attributes

Andreas Tawn andreas.tawn at ubisoft.com
Fri May 11 11:24:46 EDT 2012


> >> It's also helpful to not have to display every attribute, of which
> >> there may be dozens.
> >
> > Do I detect a code smell here?
> >
> I think so, Murphy's law dictates that the attribute you're interested in will not be
> displayed anyway.

That's what __repr__'s for.



More information about the Python-list mailing list