serializing data structures

"Martin v. Löwis" martin at v.loewis.de
Mon Jan 31 18:20:01 EST 2005


Philippe C. Martin wrote:
> I once wrote something in C to do that, but since python usually has a
> solution for me ....

If you use arbitrary data structures, you could use pickle or xmlrpclib
to marshal the data. If you know the data is restricted to a few
well-known data types, you could use XDR (Demo/rpc/xdr.py) or CORBA
(e.g. through fnorb.sf.net) to come up with a wire format.

Otherwise, if you want to define your own proprietary data format,
you can probably use the struct module to generate messages according
to this format.

However, in any case, you need to define the wire format. Once you made
a choice, Python can help implement it - but Python cannot chose a wire
format for you (although pickle comes really close, as does Dopy -
http://www.mindhog.net/~mmuller/projects/dopy/)

Regards,
Martin



More information about the Python-list mailing list