Triple-quoted strings hath not the Python-nature

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Tue Oct 21 10:58:57 CEST 2008

If triple-quoted strings had the Python-nature, then they would take
indentation into account. Thus:

     is a

would be equivalent to

    "this\n is a\n multi-line\nstring."

and not

    "this\n     is a\n     multi-line\n    string."

The rule would be: the exact same whitespace characters at the beginning of
the line on which the triple-quoted string starts must also occur at the
start of the lines on which the string continues; these are stripped off
and not included in the string contents. Any additional whitespace is of
course part of the string.

More information about the Python-list mailing list