A simple single line, triple-quoted comment is giving syntax error. Why?

Chris Angelico rosuav at gmail.com
Sat Mar 21 23:36:48 EDT 2015


On Sun, Mar 22, 2015 at 2:14 PM, Thomas 'PointedEars' Lahn
<PointedEars at web.de> wrote:
> Denis McMahon wrote:
>
>> However, you can't have multiple expressions on a line without some sort
>> of operand or separator between them.
>
> String concatenation is implicit in Python, but only with string *literals*:

Which aren't expressions. Implicit concatenation is part of the
syntax, not part of the expression evaluator.

https://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation
https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation

> (I wished other programming languages had this feature.)

But I absolutely agree. A handful do (Pike, with the same semantics as
Python; REXX, but with the proviso that any amount of whitespace
between the literals becomes a single space in the resulting string),
and it really is a very handy feature.

ChrisA



More information about the Python-list mailing list