En Sun, 14 Sep 2008 12:06:44 -0300, Michael Palmer <m_********@yahoo.ca>
escribió:
On Sep 14, 10:53 am, "inhahe" <inh...@gmail.comwrote:
>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
dumps(self).
note: __getstate__ should return the *values* to be pickled, not the
pickled state; else you end doing the work twice.
And "del those items from self.__dict__" isn't a good idea, in general;
I'd use a *copy* of __dict__ instead.
--
Gabriel Genellina