Alan Gauld wrote:
But that isn't. Python just reads the data and interprets it
as text if you specify a text file - the default - or as raw data
if you use rb.
But it DOES handle line-ends in an OS independent manner. Windows uses
CR-LF as a line end, whereas Unix, Linux, Mac use (just CR or is it LF?).
Python presents line-ends uniformly as \n when you open the file in text
mode.
Witness: (on Windows)
>>> f = open('c:/foo.txt', 'r')
>>> f.read()
'this line contains as\nbut this has as\n'
>>> f = open('c:/foo.txt', 'rb')
>>> f.read()
'this line contains as\r\nbut this has as\r\n'
[snip]
--
Bob Gailer
919-636-4239 Chapel Hill, NC
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor