unpickle from URL problem

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Wed Oct 10 08:43:11 CEST 2007

On Wed, 10 Oct 2007 05:58:51 +0000, Alan Isaac wrote:

> I am on a Windows box.
> I pickle a tuple of 2 simple objects with the pickle module.
> It pickles fine.  It unpickles fine.
> I upload to a server.
> I try to unpickle from the URL.  No luck.  Try it:
> x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example1'))
> I change the filetype to unix.  I upload again.
> I try to unpickle from the URL.  Now it works.  Try it:
> x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example2'))
> Why the difference?

Pickles are *binary* files, not text files, so make sure you always treat
them as binary, e.g. opening the files with mode 'rb' and 'wb' and don't
transmit them in text mode over FTP etc.

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list