[Tutor] class data
Mon, 3 Dec 2001 10:35:53 -0500 (EST)
OK. Using pickle and the associated example, I was able to save the class
and restore it. Either none of the data was saved or I don't know how to
access it when the class is restored.
I don't see the utility in 'pickling' a class. It's already saved in a
module (addrbook.py). I haven't tried it; but I suspect if I pickled the
class, then deleted the addrbook.py module, I would no longer be able to
unpickle the class. Or did I miss something?
- fleet -
On Sun, 2 Dec 2001, Danny Yoo wrote:
> Ah! Take a look at the 'pickle' module:
> 'pickle' knows how to deal with instances, and will properly allow you to
> save data structures as a byte stream.
> It doesn't work on pathological cases (like C extension modules or files),
> at least, not without a bit of hacking with the 'copy_reg' module.
> Try it out, and if you have problems with it, please email the list, and
> we can ferment an example.