[Python-Dev] Re: String literal concatenation & docstrings

David Goodger goodger at python.org
Sat Nov 27 16:07:15 CET 2004


[Carlos Ribeiro]
>  while the following works:
> 
>     a = "this line continues"
>         "on the next line"

Are you sure about that?  Doesn't work on my machine:

$ cat x.py
a = "this line continues "
     "on the next line"
$ python x.py
   File "x.py", line 2
     "on the next line"
     ^
SyntaxError: invalid syntax

If you add a trailing backslash, it does work:

$ cat x2.py
a = "this line continues " \
     "on the next line"
print a
$ python x2.py
this line continues on the next line

 > Kind of weird

Not weird at all ;-)

-- 
David Goodger <http://python.net/~goodger>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/python-dev/attachments/20041127/b6e5ec3c/signature.pgp


More information about the Python-Dev mailing list