how do you use pickle?

Fredrik Lundh fredrik at pythonware.com
Tue Apr 4 12:15:21 EDT 2006


John Salerno wrote:

> > but if you insist on using your own Pickler instance, you have to save
> > the pickler instance in a variable, and call the dump method on that in-
> > stance:
> >
> >     myfile = open(somefilename, "wb")
> >     mypickler = pickle.Pickler(myfile)
> >     mypickler.dump(object)
>
> I'm sorry, but I'm terribly confused. Nothing seems to be working for
> me. I *think* what I need to pickle is an image file, but so far I think
> all I'm doing is passing the file handle in as the 'object'

define "image file".  the data in the file, the file name, or some other
representation?

> I tried it both ways you suggest, but I can't get past the errors. I
> keep getting either
>
> AttributeError: 'module' object has no attribute 'dump' (when I use the
> function)

did you, by any chance, name your test script "pickle.py" ?

</F>






More information about the Python-list mailing list