'pretty print' for built in types

aspersieman aspersieman at gmail.com
Tue Dec 9 10:45:32 EST 2008


On Tue, 09 Dec 2008 17:31:41 +0200, Robert Dailey <rcdailey at gmail.com> wrote:

>
> Is there a built in way to 'pretty print' a dict, list, and tuple
> (Amongst other types)? Dicts probably print the ugliest of them all,
> and it would be nice to see a way to print them in a readable way. I
> can come up with my own function to do this, but I don't want to do
> this if I don't have to.

For lists use 'join'. 

>>> lista = ['a', 'b', 'c', 4]
>>> ','.join(lista)
>>> a,b,c,4

For more info google 'python join' or see [1]

Regards

Nicol

[1] http://docs.python.org/library/stdtypes.html#string-methods

-- 

Christopher Columbus was, after all, a super intelligent hypersquirrel from the planet Klepton. How else could he have known where to find america?



More information about the Python-list mailing list