Saving & Restoring Python objects in XML?

Tom Bridgman bridgman at
Mon Sep 23 16:22:24 EDT 2002


I'm setting up some codes where I want to save the state of the code in
an XML file at some time and reload it later to continue the processing.

It's relatively easy to save out the innards of Python objects into XML
regardless of how the objects are nested.  But what about loading this
state information back in from the XML file?  

Is there a way to write the parser handlers and/or other components (I'm
using PyXML 0.7 and higher) such that they can assemble the required
objects as they read in the file?  I'm wondering if there is an elegant
solution that might not be immediately obvious from the 'brute force'
method I keep coming up with.  I'd prefer to do this using SAX (since
I've worked with it some), but using DOM is not out of the question if
it solves the problem in a straightforward way.

Dr. William T."Tom" Bridgman           Scientific Visualization Studio
Global Science & Technology, Inc.      NASA/Goddard Space Flight Center
Email: bridgman at    Code 935
Phone: 301-286-1346                    Greenbelt, MD 20771
FAX:   TBD                   

More information about the Python-list mailing list