Pickling and inheritance are making me hurt

John J. Lee jjl at pobox.com
Sat Feb 5 19:18:01 EST 2005


Kirk Strauser <kirk at strauser.com> writes:

> I have a module that defines a Search class and a SearchResult class.  I use
> these classes by writing other modules that subclass both of them as needed
> to interface with particular search engines.
> 
> My problem is that Search defines a method (called automatically by __del__)
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Don't Do That.  __del__ methods are bad.  They mess up cyclic garbage
collection, IIRC.  ISTR other problems with them, too...


[...]
>     Exception pickle.PicklingError: <pickle.PicklingError instance at
> 0xb7f7ad6c> in <bound method Search.__del__ of <__main__.Search object at
> 0xb7ec954c>> ignored
[...]

...yeah, there's one: thanks for reminding me ;-)

You may want to read up on __getstate__ and __setstate__, BTW.


John



More information about the Python-list mailing list