Triple-quoted strings hath not the Python-nature

Robert Lehmann stargaming at gmail.com
Tue Oct 21 18:45:36 EDT 2008


On Tue, 21 Oct 2008 21:58:57 +1300, Lawrence D'Oliveiro wrote:

> If triple-quoted strings had the Python-nature, then they would take
> indentation into account. Thus:
> 
>     """this
>      is a
>      multi-line
>     string."""
> 
> 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.

"Although practicality beats purity." -- The Zen of Python, by Tim Peters

I would feel greatly offended if I had to indent all *raw* data.

-- 
Robert "Stargaming" Lehmann



More information about the Python-list mailing list