__peter__ at web.de
Sun Jan 11 09:57:32 CET 2004
Alessandro Crugnola *sephiroth* wrote:
> 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
Here's what I get (on Linux):
>>> for nl in ["\n", "\r\n", "\n\r", "\r"]:
... dst = file("tmp.txt", "wb")
... dst.write("one%stwo" % nl)
... print repr(file("tmp.txt", "U").read())
>From the documentation of file():
If Python is built without universal newline support mode 'U' is the same as
normal text mode.
So maybe you have a version without universal newline support?
More information about the Python-list