How to marshal objects to readable files?

showellshowell at gmail.com showellshowell at gmail.com
Mon Sep 15 23:03:54 EDT 2008


On Sep 14, 8:28 am, nielinjie <nielin... at gmail.com> 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.

I think YAML is the solution most targeted for your needs. To quote
the website: "YAML is a human friendly data serialization standard for
all programming languages."

   http://yaml.org/

If you're willing to sacrifice some readability for truly robust
serialization, try pickle, which isn't horribly cryptic.

If you want simplicity and AJAX interoperability, consider JSON.

If you consider Python itself to be human readable, and if your
security/performance situation does not preclude the use of eval(),
consider the PrettyPrinter module.




More information about the Python-list mailing list