cannot pickle object returned by urllib2.urlopen()
greg
greg at cosc.canterbury.ac.nz
Thu Nov 13 00:49:10 EST 2008
> On Wed, 12 Nov 2008 11:00:26 +0800, scsoce wrote:
>
>>got a exception: "a class that defines __slots__ without defining
>>__getstate__ cannot be pickled "
>>why?
Because in the absence of any other information, the default
way of pickling an object is to save the contents of its
__dict__. But an object with __slots__ doesn't necessarily
have a __dict__, and even if it does, it doesn't include
the contents of the slots. So you need to tell pickle how to
deal with it by defining __getstate__ and __setstate__ methods.
--
Greg
More information about the Python-list
mailing list