[newbie]Is there a module for print object in a readable format?

James Gan ganzhi at gmail.com
Wed Oct 19 03:39:48 CEST 2005


Hi, Steven

:) width parameter do the magic :

 >>> pprint.pprint([1,2,3,4,[0,1,2,[3,4]],5], width=1,indent=4)
[   1,
     2,
     3,
     4,
     [   0,
         1,
         2,
         [   3,
             4]],
     5]
 >>>

Steven D'Aprano wrote:
> On Mon, 17 Oct 2005 11:31:46 +0200, enrico.sirola_NOSPAM wrote:
> 
> 
>>>>>>>"James" == James Gan <ganzhi at gmail.com> writes:
>>
>>    James> I want the object printed in a readable format. For
>>
>>[...]
>>
>>    James> I tried pickled, marshel. They do different work. Is there
>>    James> another module which do this kind of job?
>>
>>from pprint import pprint
>>pprint(object)
> 
> 
> I don't think that even comes *close* to what James wants.
> 
> py> import pprint
> py> pprint.pprint([1,2,3,4,[0,1,2], 5])
> [1, 2, 3, 4, [0, 1, 2], 5]
> 
> 



More information about the Python-list mailing list