[Python-Dev] String literal concatenation & docstrings

Brett C. bac at OCF.Berkeley.EDU
Sat Nov 27 20:08:34 CET 2004


Guido van Rossum wrote:
>>It means that:
>>
>>    print "this line continues"
>>          "on the next line"
>>
>>does not work, while the following works:
>>
>>    a = "this line continues"
>>        "on the next line"
> 
> 
> As has been pointed out already, it doesn't.
> 
> The right way to look at this is not using the statement/expression
> distinction, but to look at whether the newline between the two
> literals is significant to the parser or not. A significant newline
> ends a statement; an insignificant one is equivalent to a space. The
> rule is that newlines (outside string quotes anyway) are significant
> unless either escaped with \, or contained within matching
> parentheses.
> 

So how is this for new wording?

"Multiple adjacent string literals (delimited by whitespace), possibly using 
different quoting conventions, are allowed, and their meaning is the same as 
their concatenation as long as the newline separating them is not signifcant to 
the parser."


More information about the Python-Dev mailing list