Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48942 > unrolled thread

Re: n00b question on spacing

Started byDennis Lee Bieber <wlfraed@ix.netcom.com>
First post2013-06-22 15:17 -0400
Last post2013-06-22 15:17 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: n00b question on spacing Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-22 15:17 -0400

#48942 — Re: n00b question on spacing

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-06-22 15:17 -0400
SubjectRe: n00b question on spacing
Message-ID<mailman.3704.1371928672.3114.python-list@python.org>
On Sat, 22 Jun 2013 10:43:14 -0700, Mark Janssen
<dreamingforward@gmail.com> declaimed the following:

>> Also remember when entering long lines of text that strings concatenate
>> within parenthesis.
>> So,
>> ("a, b, c"
>> "d, e, f"
>> "g, h, i")
>>
>> Is the same as ("a, b, cd, e, fg, h, i")
>
>There was a recent discussion about this (under "implicit string
>concatenation").  It seems this is a part of the python language
>specification that was simply undefined.   (A rule probably should be
>added to the lexer to make this explicit.)

	Really? From the language reference manual:

"""
2.4.2. 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).
"""

	Maybe the combination of literal concatenation with the implicit line
continuation of an open ([{ isn't obvious, but does it need to be
explicitly documented?

-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web