Data::Dumper for Python

Edward wijaya ewijaya at singnet.com.sg.removethis
Thu Oct 28 20:18:38 CEST 2004


Thanks for the informative reply, Dave.
I really appreciate that, for me as a new guy
in Python.

Regards,
Edward WIJAYA
On Thu, 28 Oct 2004 18:06:12 -0000, Dave Benjamin 
<ramen at lackingtalent.com> wrote:

> In article <opsgkj8cih074qab at news.singnet.com.sg>, Edward wijaya wrote:
>> Is there any equivalent of it
>> in Python?
>
> Take a look at the "pprint" module. Also, it's worth noting that the 
> Python
> interpreter prints representations of data structures all the time, no
> library required:
>
>>>> x = [{'a': a, 'b': b} for a in range(2) for b in range(3)]
>>>> x
> [{'a': 0, 'b': 0}, {'a': 0, 'b': 1}, {'a': 0, 'b': 2}, {'a': 1, 'b': 0},
> {'a': 1, 'b': 1}, {'a': 1, 'b': 2}]
>
> Read up on the __repr__ and __str__ methods to understand how this 
> mechanism
> works and how to extend it to your own objects.
>



More information about the Python-list mailing list