How to marshal objects to readable files?

Michael Palmer m_palmer45 at
Tue Sep 16 03:03:08 CEST 2008

On Sep 14, 11:28 am, nielinjie <nielin... at> wrote:
> Hi list:
> I just want to marshal objects (instance of custom classes)to a human
> *READABEL *file/string, and also, I want unmarshal it back. in xml
> format or any other format.
> Any advice? Which lib should I use?
> Thanks a lot.

There is module pickle in the standard library. It's output is not all
that bad (in text mode, that is). If you don't like it, it would still
be a good starting point for a custom serializer - it does all the
tree walking for you, so you would only have to customize the strings
it writes and reads back in.

More information about the Python-list mailing list