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


Groups > comp.lang.python > #48942

Re: n00b question on spacing

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: n00b question on spacing
Date 2013-06-22 15:17 -0400
Organization IISS Elusive Unicorn
References <CAJ=2b07ETuSuo2+3Xu6vMOJA+q1JwUFTezO3LaYLG8wXd+FLBQ@mail.gmail.com> <24094189.2779.1371851333304.JavaMail.rgacote@ip-225.appropriatesolutions.com> <CAMjeLr9iQ2Yg_YF0cSD2a9fK5upSgK42wZeNN9R8Ee2-rWKzGA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3704.1371928672.3114.python-list@python.org> (permalink)

Show all headers | View raw


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/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web