robert.kern at gmail.com
Fri Jan 30 00:13:41 CET 2009
On 2009-01-29 08:20, Aahz wrote:
> The reason I'm chiming in is that I would welcome a PEP that created a
> __pprint__ method as an alternative to special-casing. I think that it
> would be generically useful for user-created objects, plus once you've
> added this feature other people can easily do some of the grunt work of
> extending this through the Python core. (Actually, unless someone
> objects, I don't think a PEP is required, but it would be good for the
> usual reasons that PEPs are written, to provide a central place
> documenting the addition.)
I think it's worth looking at Armin Ronacher's pretty.py for a starting point.
I've been using it as my default displayhook under IPython for a few weeks now.
It uses a combination of a function registry and a __pretty__ special method to
find the right pretty printer.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-Dev