Save/Store whole class (or another object) in a file

alexLIGO at googlemail.com alexLIGO at googlemail.com
Wed Oct 18 10:33:21 EDT 2006


Hi,

thanks for the reply,but unfortunately this does not work with the type
of classes I am dealing with. When trying to pickle the class I get the
following error:

 File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
    raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__
cannot be pickled

So there is something missing in this class? Or any other idea how to
do this?

Alex


Sybren Stuvel wrote:
> alexLIGO at googlemail.com enlightened us with:
> > is it possible in python (with/without matplotlib, numpy etc) to
> > store a whole class with its data into a file
>
> Check out the pickle module.
> 
> Sybren
> -- 
> Sybren Stüvel
> Stüvel IT - http://www.stuvel.eu/




More information about the Python-list mailing list