the usage of pickle

Thomas Weholt thomas at gatsoft.no
Fri Aug 10 06:12:08 EDT 2001


AFAIK, pickle doesn't handle code-objects like functions. Use the
marshall-module instead. Ordinary objects like lists, dictionaries etc.
works fine with pickle. ( And by the way, use cPickle for speed. It helps
alot )

thomas

"Dino Hsu" <dino1_nospam at ms1.hinet.net> wrote in message
news:egb7nt4ba7iusumbjsd8thqhd0j943c1qf at 4ax.com...
> Dear all,
>
> When I try pickle.dump(...), it always fails, anyone show me how?
> Thanks in advance.
>
> >>> def f():
> return '123456'
> >>> f
> <function f at 01215F2C>
>
> >>> pickle.dump(f,'test.txt')
> Traceback (most recent call last):
>   File "<pyshell#60>", line 1, in ?
>     pickle.dump(f,'test.txt')
>   File "c:\python21\lib\pickle.py", line 939, in dump
>     Pickler(file, bin).dump(object)
>   File "c:\python21\lib\pickle.py", line 104, in __init__
>     self.write = file.write
> AttributeError: write
>
> Dino
>





More information about the Python-list mailing list