how do you use pickle?

John Salerno johnjsal at NOSPAMgmail.com
Tue Apr 4 12:31:25 EDT 2006


Fredrik Lundh wrote:
> 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" ?

DOH!



More information about the Python-list mailing list