pprint and ">>>"

Peter Hansen peter at engcorp.com
Wed Sep 24 20:31:13 CEST 2003

Shu-Hsien Sheu wrote:
> Sometimes, it is find of nice using:
> print >> my_file_object, my_variabels
> than using the standard f.write.
> However, it cannot be done with pprint.pprint.

I suspect you are looking for either the second argument to pprint(),
or pprint.pformat() instead.

   pprint.pprint(my_variables, my_file_object)


   print >>my_file_object, pprint.pformat(my_variables)


More information about the Python-list mailing list