Wednesday, August 11, 2010

Any good module for saving settings file?

I'm thinking about the file format for various settings.
Using XML is like going to a super market by jet plane. YAML is good but not in the standard module.
So far the best choice is using JSON but json module in the standard module is not suitable for my needs since it has no __getstate__/__setstate__ equivalent.

I wonder if there's a nice module that has both pickle and json features. It would

- be able to serialize arbitrary object
- have __getstate__, __setstate__ equivalent
- be able to convert to/from standard Python objects (NOT Tag/Node/Element object ! )
- create json formatted file
- preferably customize the behavior on error
- be a light weight module (not dependent on thousands of other modules)

There's no need to maintain object references, dump() can raise an exception just like json.
I can make one by myself but I don't want to reinvent the wheel. Anybody knows if it exists already?