[Python-Dev] Multiline Strings confusion it tutorial

Ethan Furman ethan at stoneleaf.us
Sat Apr 13 01:55:15 CEST 2013


On 04/12/2013 03:58 PM, Christian Tismer wrote:
> I wanted to point a bling guy to the Python wiki:
>
> http://wiki.python.org/moin/BeginnersGuide/Programmers/SimpleExamples#preview
>
> and when reading a little bit, I found the entry on multiline strings.

This entry?

Defining multiline strings

string = '''This is a string with embedded newlines.
Also known as a tripled-quoted string.
     Whitespace at the beginning of lines is included,
so the above line is indented but the others are not.
'''


> I found that example pretty contorted, because this is not a multiline string.
> Instead, there are multiple lines which define a single line string!
> Actually, the construct is even syntactically nothing else than a single
> line string which is handled by the parser, already.

That string has four (4) embedded '\n's -- that makes it multiline.

> A multiline string is IMHO a string which value covers multiple lines, after whatever
> pre-processing was done. I don't think the given example is very helpful,
> but adds confusion.

And that string does cover multiple lines.


> Where would I add such a complaint, usually?
> Or should I simply fix it?

Nothing broken here, move along, nothing to see...

--
~Ethan~


More information about the Python-Dev mailing list