how to exclude specific things when pickling?

Michael Palmer m_palmer45 at
Sun Sep 14 17:06:44 CEST 2008

On Sep 14, 10:53 am, "inhahe" <inh... at> wrote:
> If I gather correctly pickling an object will pickle its entire hierarchy,
> but what if there are certain types of objects anywhere within the hierarchy
> that I don't want included in the serialization?  What do I do to exclude
> them?   Thanks.

If your class defines a  __getstate__ method, it is expected to return
the pickled state of the entire class. You can for example del those
items from self.__dict__ that you don't want pickled and then return

More information about the Python-list mailing list