Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'operator': 0.03; '(even': 0.05; 'explicitly': 0.05; '"""': 0.07; 'continuation': 0.07; 'expressions': 0.07; 'level,': 0.07; 'lines,': 0.07; 'needed,': 0.07; 'string': 0.09; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thus,': 0.09; 'underscore': 0.09; 'subject:question': 0.10; 'python': 0.11; 'adjacent': 0.16; 'backslashes': 0.16; 'concatenate': 0.16; 'janssen': 0.16; 'lexer': 0.16; 'literals': 0.16; 'message- id:@4ax.com': 0.16; 'quoted': 0.16; 'really?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'syntactical': 0.16; 'undefined.': 0.16; 'component': 0.16; 'sat,': 0.16; 'language': 0.16; 'discussion': 0.18; 'split': 0.19; 'seems': 0.21; 'url:home': 0.24; 'equivalent': 0.26; 'possibly': 0.26; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'feature': 0.29; 'comments': 0.31; 'lines': 0.31; '-0700,': 0.31; 'implicit': 0.31; 'styles': 0.31; 'probably': 0.32; 'run': 0.32; 'text': 0.33; 'open': 0.33; 'implemented': 0.33; 'raw': 0.33; 'maybe': 0.34; 'but': 0.35; 'add': 0.35; 'combination': 0.36; 'skip:> 10': 0.36; 'should': 0.36; 'so,': 0.37; 'received:76': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'simply': 0.61; 'different': 0.65; 'within': 0.65; 'obvious,': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: n00b question on spacing Date: Sat, 22 Jun 2013 15:17:42 -0400 Organization: IISS Elusive Unicorn References: <24094189.2779.1371851333304.JavaMail.rgacote@ip-225.appropriatesolutions.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: adsl-76-249-22-77.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371928672 news.xs4all.nl 15901 [2001:888:2000:d::a6]:42355 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48942 On Sat, 22 Jun 2013 10:43:14 -0700, Mark Janssen 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/