pickle module doens't work

Omer Korat animus.partum.universum at gmail.com
Thu Dec 27 07:05:02 EST 2012


You're probably right in general, for me the 3.3 and 2.7 pickles definitely don't work the same:

3.3:
>>> type(pickle.dumps(1))
<type 'bytes'>

2.7:
>>> type(pickle.dumps(1, pickle.HIGHEST_PROTOCOL))
<type 'str'>


As you can see, in 2.7 when I try to dump something, I get useless string. Look what I gen when I dump an NLTK object such as the sent_tokenize function:

'\x80\x02cnltk.tokenize\nsent_tokenize\ng\x00'

Now, this is useless. If I try to load it on a platform without NLTK installed on it, I get:

ImportError: No module named 'nltk'

So it means the actual sent_tokenizer wasn't saved. Just it's module.



More information about the Python-list mailing list