pickle module doens't work

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

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

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

>>> 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:


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