[Python-ideas] More helpers in reprlib (was Re: doctest)

Nick Coghlan ncoghlan at gmail.com
Wed Feb 29 00:07:13 CET 2012


On Wed, Feb 29, 2012 at 8:19 AM, Barry Warsaw <barry at python.org> wrote:
> On Feb 27, 2012, at 05:44 PM, Ian Bicking wrote:
>
>>Doctest needs reliable repr's more than reversable repr's, and you can create
>>them using that.  You'll still get a lot of <foobar.Foobar object at
>>0x391a9df> strings, which suck... but if you are committed to doctest then
>>maybe better to provide good __repr__ methods on your custom objects!
>
> +1 even if you don't use doctests!  I can't tell you how many times adding a
> useful repr has vastly improved debugging.  I urge everyone to flesh out your
> reprs with a little bit of useful information so you can quickly identify your
> instances at a pdb prompt.

Since this question came up recently, what do you think of adding some
more helpers to reprlib to make this even easier to do?

I know I just added some utility functions to PulpDist [1] to avoid
reinventing that particular wheel for each of my class definitions.

Cheers,
Nick.

[1] http://git.fedorahosted.org/git/?p=pulpdist.git;a=blob;f=src/pulpdist/core/util.py

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list