[Zope-dev] Pretty print from Python Script

Andy McKay andy@agmweb.ca
Tue, 3 Sep 2002 09:53:38 -0700


If im doing quick debugging its simple to write a Python Script TTW and view
the results. However using printed for a large data structure can be a
nightmare for debugging as it scrolls off the end of the page. So I imported
pprint.pformat and I was happy again.

But now I want by default printed to return pformat text. Since this will
break nothing of mine, but stop me worrying when I want to quickly print a
dict / list etc for debugging purposes. I thought it would be a simple
matter of changing lib\python\RestrictedPython\PrintCollector.py, but it
gets a string already in the write method.

After that it got complicated and figuring I've spent 10 more minutes on
this than necessary I thought I'd ask if anyone knew off the answer off the
top of their head...

Cheers.
--
  Andy McKay
  Agmweb Consulting
  http://www.agmweb.ca