Quinten (4) [Avatar] Offline
#1
Dear Anthony Briggs,

I have a question about page 80 where you are speaking about pickle a standard library. On the command line the result of typing >>> import pickle is:
"AttributeError: 'module' object has no attribute 'dump"
>>> import textwrap
>>>
is quit right.
Why is pickle not working?(there is no typo, I think...)
Regards,
Quinten
anthony.briggs (30) [Avatar] Offline
#2
Re: import pickle
Hi Quinten,

There shouldn't be any reason for that statement to fail. Here's the result of running the same thing on my computer:

C:UsersAnthony>python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> pickle.dump
<function dump at 0x0281D630>

dump is a function within the pickle module, so pickle.dump will give you the function object itself.

There are a couple of things that I can think of which might give you that error:
you have a file called pickle.py inside your directory which is overriding the built-in module.
there's something else that you missed with your cut and paste (just importing a module shouldn't give you that error, even if there isn't any 'dump' function within it.
there's something odd about your Python install.

It might also help to know what operating system you're running.

Thanks,

Anthony
Quinten (4) [Avatar] Offline
#3
Re: import pickle
Anthony,

Thanks for your answer. You have brought me on the right track. I use python 2.5 and 3.0. With 3.0 there is no problem. Import pickle is working there. The problem was my Python install of Python 2.5, obvious.

With regards,
Quinten.

P.S I use windows XP on win32