Dino Viehland wrote:
> My understanding is that users can write code that uses only \n and Python 
> will write the end-of-line character(s) that are appropriate for the platform 
> when writing to a file.  That's what I meant by uses \n for everything 
> internally.
>
> But if you write \r\n to a file Python completely ignores the presence of the 
> \r and transforms the \n into a \r\n anyway, hence the \r\r in the resulting 
> stream.  My last question is simply does anyone find writing \r\r\n when the 
> original string contained \r\n a useful behavior - personally I don't see how 
> it is.
>
> But Guido's response makes this sound like it's a problem w/ VC++ stdio 
> implementation and not something that Python is explicitly doing.  Anyway, 
> it'd might be useful to have a text-mode file that you can write \r\n to and 
> only get \r\n in the resulting file.  But if the general sentiment is 
> s.replace('\r', '') is the way to go we can advice our users of the behavior 
> when interoperating w/ APIs that return \r\n in strings.
>   

We always do replace('\r\n','\n') but same difference...

Michael

>
> -----Original Message-----
> From: "Martin v. Löwis" [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 26, 2007 3:01 PM
> To: Dino Viehland
> Cc: python-dev@python.org
> Subject: Re: [Python-Dev] New lines, carriage returns, and Windows
>
>   
>> This works great as long as you stay within an entirely Python world.
>> Because Python uses \n for everything internally
>>     
>
> I think you misunderstand fairly significantly how this all works
> together. Python does not use \n "for everything internally". Python
> is well capable of representing \r separately, and does so if you
> ask it to.
>
>   
>> So I'm curious: Is there a reason this behavior is useful that I'm
>> missing?
>>     
>
> I think you are missing how it works in the first place (or else
> you failed to communicate to me what precise behavior you find
> puzzling).
>
> Regards,
> Martin
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
>
>   

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to