[Tutor] class data
Mon, 3 Dec 2001 10:53:55 -0500
On Mon, Dec 03, 2001 at 10:35:53AM -0500, firstname.lastname@example.org wrote:
| 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?
You want to (un)pickle the instance of the class. That is where the
usefulness is. And, yes, you do need to keep the source around in
order to successfully unpickle the objects.
Alternatively you could practice file IO and devise your own format
for persistantly storing the data.
For society, it's probably a good thing that engineers value function
over appearance. For example, you wouldn't want engineers to build
nuclear power plants that only _look_ like they would keep all the
(Scott Adams - The Dilbert principle)