pretty, a python pprint successor

The ubuntuusers team acquired two new webdesigners this week and the first thing that they missed was a var_dump replacement. In fact that thing is really missing. Python does have a pprint library but it’s not extensible. Impossible to dump normal objects.

I worked today on a port of ruby’s pp library (wanted to call it pp, but that’s already reserved by parallel python). Check it out in the cheeseshop: pretty.

Classes can implement __pretty__ to prettyprint their structure.

I would love to see that as replacement for the builtin pprint library which is impossible to extend. pretty is not yet 100% backwards compatible, some reprs look different, but that’s extensible. Check out the module docstring for some examples.

Leave a Reply

cogitations driven by wordpress