os.linesep under Windows
andres at corrada.com
andres at corrada.com
Tue May 30 17:35:53 EDT 2000
On Tue, May 30, 2000 at 05:21:34PM -0400, Fred L. Drake, Jr. wrote:
>
> The C stdio functions convert '\n' to the underlying operating
> system's line separator; that's what their supposed to do. (The stdio
> functions are the ones that operate on FILE* values, not file
> descriptors.) So '\n' converts to '\x0D\x0A' ('\r\n') in the C
> libraries, and that's what appears in the file. The '\x0D\x0A' is
> converted back to '\n' when read back in.
> Note that these conversions are not performed if the file is opened
> in binary mode; open(..., 'wb') does not enable this conversion.
> This doesn't actually have much to do with Python, but rather with
> the underlying libraries.
Fred,
Thanks for this explanation. It reminded me of a question I have asked
before but never got a clear answer. If this is due to Python's C
implementation, what happens in JPython? Does Java follow the same
convention?
------------------------------------------------------
Andres Corrada-Emmanuel Email: andres at corrada.com
------------------------------------------------------
More information about the Python-list
mailing list