readling newlines
Samuel Walters
swalters_usenet at yahoo.com
Sun Jan 11 02:47:26 EST 2004
|Thus Spake Alessandro Crugnola *sephiroth* On the now historical date of
Sat, 10 Jan 2004 14:25:44 +0000|
> Hi, I'm trying to detect the newlines method of a file opened. I'm using
> the 'U' mode as parameter when opening a file, but for every file opened
> the result is always "\r\n", even if the file has been saved with the
> "\n" newline method. Is there i'm missing?
>
> I'm on Windows with python 2.3.3
Not quite sure what "U" mode is, but try adding the "b" mode when opening
the file. Windows makes a distinction between binary and text files.
Python defaults to text mode, and since newlines for windows text is \r\n,
that's what Python puts there.
HTH
Sam Walters.
--
Never forget the halloween documents.
http://www.opensource.org/halloween/
""" Where will Microsoft try to drag you today?
Do you really want to go there?"""
More information about the Python-list
mailing list