Trying to understand pickle.loads withou class declaration

Sébastien Boisgérault Sebastien.Boisgerault at gmail.com
Sun May 29 08:11:05 EDT 2005


Even

    class A:
        pass

should do the trick. Only the instance attributes are saved by a
pickle,
not the methods or the class itself. The unpickler tries to merge the
saved data and the class/method info that is not saved to recreate
the fully functional instance... but of course this info should still
be available. The unpickler will even import the class from the
appropriate module if necessary.

If you want your unpickler to manufacture a class for you when
it is not available, you may use the gnosis xml pickler with the
appropriate security ("paranoia") level.

http://gnosis.cx/download/gnosis/xml/pickle/

Cheers,

Seb




More information about the Python-list mailing list