How to iterate throuhg dictionary

Mark Robinson m.1.robinson at herts.ac.uk
Wed Aug 8 11:29:36 EDT 2001


Sorry to be a pain in the rear, but I have tried this with dicts 
containing nultiply nested lists and it is still printing it all on one 
line.

Strange.......and annoying cos it sounds like something I would  use alot

cheers
blobby

François Pinard wrote:

>> François Pinard wrote:
> 
>>> It is often nice to do:
>>>         import pprint
>>>         pprint.pprint(d)
>> 
> 
> [Mark Robinson]
> 
>> I just had a quick play with that, and I can't see any difference between
>> your example verbatum and simply print d.
> 
> 
> Oh, then your `d' should be simple.  `pprint.pprint' would print long or
> complex structures on multiple lines, all nicely indented.  Dictionaries
> entries are shown sorted by key.  I find it so useful that I forever had:
> 
>     import pprint
>     pp = pprint.pprint
> 
> in my `.pythonrc' filean I could use thinks like `pp(d)' interactively.
> 





More information about the Python-list mailing list