[Pythonmac-SIG] Re: [Python-Dev] Import hook to do end-of-line conversion?

Guido van Rossum guido@digicool.com
Mon, 09 Apr 2001 21:41:54 -0500


> > If a program is running on a windows box, and writing a file on a *nix
> > server, what kind of line ending should it write? Would it even know
> > what the native format is on the server? It seems we would need to be
> > able to specify the line ending format explicitly for writing.
> 
> Yes, I think that's the best that can be done. To do any better
> would require all file servers to be aware of the text/binary
> distinction and be willing to translate, and for there to be
> some way for the Python file object to communicate to the OS
> which mode is intended. Neither of these things are true in
> general.

You might need to be able to specify a specific line ending format,
but there should also be a default -- and it should be the default
appropriate to the OS.  So, \n on Unix, \r\n on Windows, \r on Mac
running in "Mac mode", and \n on MacOS X running in "Unix mode".

--Guido van Rossum (home page: http://www.python.org/~guido/)