On Thu, Aug 15, 2013 at 10:46 AM,  <wxjmfa...@gmail.com> wrote:
> A technical ascpect of triple quoted strings is
> that the "end of lines" are not respected.
>
>>>> import zzz
>>>> zzz.__doc__
> 'abc\ndef\n'
>>>> with open('zzz.py', 'rb') as fo:
> ...     r = fo.read()
> ...
>>>> r
> b'"""abc\r\ndef\r\n"""\r\n'
>
> Now, one can argue...

Actually, they are respected. Triple-quoted strings are parsed after
the file is read in, and newline handling is dealt with at an earlier
level, same as encodings are. You wouldn't expect that string to
retain information about the source file's encoding, and nor do you
expect it to retain the source file's newline style. A newline is
represented in the file on disk as \r\n or \n (or something else,
even), and in the string as \n. It's that simple.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to