[Tutor] class data
Mon, 03 Dec 2001 10:53:47 -0500
addrbook.py contains the python instructions to implement the addressbook. It does NOT contain
the data that makes up the addressbook. pickling is used to save the data that was entered
using the addrbook module.
If you give someone your addrbook.py module, you are giving them a computer program.
You are NOT giving them your addressbook.
> 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.
> Tutor maillist - Tutor@python.org
1 Court Street, Suite 378
Lebanon, NH 03766-1358