windows to linux pickled objects?
Stephen Boulet
stephen at theboulets.net
Wed Nov 28 08:22:20 EST 2001
Oleg Broytmann wrote:
> On Tue, Nov 27, 2001 at 11:05:08PM -0600, Stephen Boulet wrote:
>> I pickled a list in windows but couldn't open it in linux without first
>> running the handy dos2unix program on it.
>
> Always write binary data to binary files:
>
> outfile = open(filename, 'wb')
> outfile.write(pickle)
> outfile.close()
>
> Oleg.
Thanks to you both for the responses.
But is writing in binary mode supported under linux? The tutorial says:
<<
On Windows and the Macintosh, 'b' appended to the mode opens the file in
binary mode
>>
I tried it on linux and the program did run, but the size of the pickled
file only went down from 8183905 bytes to 8180057 bytes, and the file
wasn't binary at all. Maybe the size difference can be explained by the
lack of carriage returns. ;)
It would be nice if the binary option worked on linux...
-- Stephen
More information about the Python-list
mailing list