launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #02557
Re: Give your models some repr love!
On Feb 12, 2010, at 04:21 AM, Martin Pool wrote:
>We have http://doc.bazaar.canonical.com/bzr.dev/developers/HACKING.html#object-string-representations
>if you want to borrow it.
There are some good guidelines in this, but I personally differ in a few
details.
* I like using the '<Thing ...>' style that you see in many of Python's own
reprs. Using __class__.__name__ for what follows the left bracket is a good
recommendation.
* If a colon follows the class name or not is debatable. I've seen it done
both ways.
* Using repr() for subobjects inside the parent object on a case-by-case
basis. Do it if it makes things more readable.
-Barry
Attachment:
signature.asc
Description: PGP signature
References