Here's what I have:

import pickle

data = open(r'C:\pickle_data.txt', 'w')
image = open(r'C:\peakhell.jpg')
pickle.Pickler(data)
data.dump(image)
data.close()
image.close()

First off, I'm not sure the second line is the way to do that. But my 
main problem is I don't know how to define the steps when pickling an 
object. How do you first create the object? Does it return a value? I tried:

pickler = pickle.Pickler(data)
pickle.Pickler(data)

Then I tried:

pickler.dump(image)
data.dump(image)

Basically, I'm just confused about all the syntax involved. Which 
objects do I operate on, and when? I can't find these answers in the 
documentation or in the interactive help, because I don't see any examples.

Furthermore, I get this error every time:

Traceback (most recent call last):
   File "C:\Documents and Settings\jsaler01.TUFTS\My 
Documents\Python24\myscripts\challenges\pickle.py", line 3, in -toplevel-
     import pickle
   File "C:\Documents and Settings\jsaler01.TUFTS\My 
Documents\Python24\myscripts\challenges\pickle.py", line 7, in -toplevel-
     pickle.Pickler(data)
AttributeError: 'module' object has no attribute 'Pickler'

So that makes me really confused, because I must have the syntax totally 
wrong if it can't even get past the initial creation of a pickler object.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to