Fredrik Lundh wrote:

> file handles does not belong to that group (what did you expect
> pickle to do with a file handle ?)
> 
> or did "object" refer to the Pickler instance?  you don't really need to
> bother with that; just use the dump *function* instead:
> 
>     pickle.dump(object, file)
> 
> 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', which 
probably isn't correct. How would I get the actual image object to pass 
in? But I also tried pickling a string and that didn't work either.

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)

or

AttributeError: 'module' object has no attribute 'dump' (when I create 
an instance)

Is there something special I need to do to use the pickle module? My 
program seems to recognize the import, but it keeps saying that nothing 
is an attribute of it.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to