Save/Store whole class (or another object) in a file
gagsl-py at yahoo.com.ar
Wed Oct 25 23:55:12 CEST 2006
At Wednesday 25/10/2006 11:32, alexLIGO at googlemail.com wrote:
>Fredrik Lundh wrote:
> > alexLIGO at googlemail.com wrote:
> > > 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?
> > did you remember to read the error message before posting ?
>of course I read the error-message, I understand the error-message, BUT
>this message is not telling me how anyway to save the data of such a
>class in a file! It does not tell me, that there is absolutely no way
>to do that. Maybe there is, maybe there is not.
>Thats why I am posting it here!
"A man who wears a hat without buying a ticket cannot enter the theatre"
You wear a hat, you want to enter: either buy your ticket or forget
about your hat.
In this case, just define a __getstate__ method (read the pickle
docs), or forget about __slots__.
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
More information about the Python-list