Why 'r' mode anyway? (was: Re: Pickled text file causing ValueError (dos/unix issue))
Irmen de Jong
irmen at -nospam-remove-this-xs4all.nl
Fri Jan 14 12:55:19 EST 2005
Tim Peters wrote:
> Yes: regardless of platform, always open files used for pickles in
> binary mode. That is, pass "rb" to open() when reading a pickle file,
> and "wb" to open() when writing a pickle file. Then your pickle files
> will work unchanged on all platforms. The same is true of files
> containing binary data of any kind (and despite that pickle protocol 0
> was called "text mode" for years, it's still binary data).
I've been wondering why there even is the choice between binary mode
and text mode. Why can't we just do away with the 'text mode' ?
What does it do, anyways? At least, if it does something, I'm sure
that it isn't something that can be done in Python itself if
really required to do so...
More information about the Python-list