GNU Info

Info Node: (python2.1-ref.info)String literal concatenation

(python2.1-ref.info)String literal concatenation


Next: Unicode literals Prev: String literals Up: Literals
Enter node , (file) or (file)node

String literal concatenation
----------------------------

Multiple adjacent string literals (delimited by whitespace), possibly
using different quoting conventions, are allowed, and their meaning is
the same as their concatenation.  Thus, `"hello" 'world'' is equivalent
to `"helloworld"'.  This feature can be used to reduce the number of
backslashes needed, to split long strings conveniently across long
lines, or even to add comments to parts of strings, for example:

     re.compile("[A-Za-z_]"       # letter or underscore
                "[A-Za-z0-9_]*"   # letter, digit or underscore
               )

Note that this feature is defined at the syntactical level, but
implemented at compile time.  The `+' operator must be used to
concatenate string expressions at run time.  Also note that literal
concatenation can use different quoting styles for each component (even
mixing raw strings and triple quoted strings).


automatically generated by info2www version 1.2.2.9