Binary vs. Text mode

andres at corrada.com andres at corrada.com
Sat Dec 2 00:11:41 EST 2000


As I have read in previous postings, this is not a feature of Python but
rather a feature of C. This 'feature' regularly bites people working on Macs
and PCs. On Unix, C's behavior is transparent but on Macs '\n' is converted
to '\r' while on Win32 '\n' is converted to '\r\n'.

The end result is that you don't have to make any extra efforts to write
portable code that will correctly parse text streams.

On Thu, Nov 30, 2000 at 07:04:55AM -0700, Dave Brueck wrote:
> Hi Ben,
> 
> On Windows the newline character ('\n') is silently replaced on-the-fly with
> '\r\n' when you read and write in text mode. This goofiness invalidates the
> numbers used by seek/tell. In binary mode (aka "not broken mode") no
> translation occurs... dumb, huh?
> 
> -Dave
> 

------------------------------------------------------
Andres Corrada-Emmanuel   Email: andres at corrada.com
------------------------------------------------------




More information about the Python-list mailing list