[IPython-user] Re: String render

Fernando Perez Fernando.Perez at colorado.edu
Tue Jul 26 16:41:00 CDT 2005


Robert Kern wrote:
> Damien DEGOIS wrote:
> 
>>Hello,
>>
>>i'd like to know what's the function used to format tuples,dicts, etc
>>with indentation when output ex:
>>
>>In [16]: a = ['abc','def','ghi','jkl',{'a':1,'b':2,'c':3,'d':4,'e':5,'f':['aze','qsd']},{'aze':123,'eza':654}]
>>In [17]: a
>>Out[17]: 
>>['abc',
>> 'def',
>> 'ghi',
>> 'jkl',
>> {'a': 1, 'c': 3, 'b': 2, 'e': 5, 'd': 4, 'f': ['aze', 'qsd']},
>> {'aze': 123, 'eza': 654}]
>>
>>
>>And i would like to know how i can reuse it in my scripts (is it
>>ipython specific or not ?) ?
> 
> 
> Look at the pprint module.

Yup, that's what ipython uses.  The %Pprint magic toggles it on/off:

In [1]: %Pprint
Pretty printing has been turned OFF

In [2]: %Pprint
Pretty printing has been turned ON


Cheers,

f




More information about the IPython-user mailing list