In other words, what's the sprintf equivalent to pprint?
+2
A:
Assuming you really do mean pprint
from the pretty-print library, then you want
the pprint.pformat
method.
If you just mean print
, then you want str()
Andrew Jaffe
2009-02-06 18:29:47
+1
A:
Something like this:
import pprint, StringIO
s = StringIO.StringIO()
pprint.pprint(some_object, s)
print s.getvalue() # displays the string
Hans Nowak
2009-02-06 18:30:04