Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'element': 0.07; 'string': 0.09; '22,': 0.09; 'literal': 0.09; 'subject:Why': 0.09; 'cc:addr :python-list': 0.11; '"o"': 0.16; 'ast': 0.16; 'cares': 0.16; 'code),': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'literal.': 0.16; 'literals.': 0.16; 'subject: \n ': 0.16; 'subject:comment': 0.16; 'subject:quoted': 0.16; 'subject:simple': 0.16; 'subject:triple': 0.16; 'syntactic': 0.16; 'syntax,': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'byte': 0.24; 'cc:2**0': 0.24; 'header :In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'included': 0.31; "skip:' 10": 0.31; 'implicit': 0.31; 'used,': 0.33; 'knows': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'skip:m 40': 0.38; 'pm,': 0.38; 'skip:p 20': 0.39; 'expression': 0.60; 'information': 0.63; 'kind': 0.63; 'more': 0.64; 'thomas': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'mar': 0.68; 'reads': 0.68; '2015': 0.84; 'regular,': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Tr77hnEaGr5QCUbY2MyBDc81Ymjt71rog27uybQkk6c=; b=X9OHbXEj+OgjNyteChj2Mm63aVcVmAWJxUj7WXfM19HTH9r0DE+Nm9ta/vZdumDIcz g6FpY1zgP707F6GP4VJgYHAhIr3/p6VhEb/JjVLVdnb1pFm8U4VvS6A3NGlVskvCyHOL N/RU0OEr7jWWduw7bhj0lAOSlzWEVIoCuDAWcrdV8xkvdo2CgWnAvE0xulTM0gkyCwSm lVYjhJYO/BFvalVBe3kYJBCQKoEPuI/uKH3Cu/s+2Mrfs54ZlBE+DbfnTGJM4OAQs9PW WmvYs4AZ9a6apMe+W1CF058wF+zKywxp0C0ixnQdI2oWJrhSDZFTgfwVpwUP6EdTJqne YHTA== MIME-Version: 1.0 X-Received: by 10.107.160.212 with SMTP id j203mr16763465ioe.43.1426997513513; Sat, 21 Mar 2015 21:11:53 -0700 (PDT) In-Reply-To: <3971951.908YQu3oQO@PointedEars.de> References: <3533816.ZYnZ2OzjCs@PointedEars.de> <3971951.908YQu3oQO@PointedEars.de> Date: Sun, 22 Mar 2015 15:11:53 +1100 Subject: Re: A simple single line, triple-quoted comment is giving syntax error. Why? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1426997516 news.xs4all.nl 2893 [2001:888:2000:d::a6]:41647 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87813 On Sun, Mar 22, 2015 at 2:49 PM, Thomas 'PointedEars' Lahn wrote: >> Implicit concatenation is part of the syntax, not part of the expression >> evaluator. > > Reads like nonsense to me. What do you mean? String concatenation by abuttal is as much a syntactic element as the distinction between regular, raw, and triple-quoted string literals. By the time you get to AST (never mind about byte code), that information is gone: >>> print(ast.dump(ast.parse(""" ... x = '''hello''' ... """))) Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))]) >>> print(ast.dump(ast.parse(""" ... x = r'hello' ... """))) Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))]) >>> print(ast.dump(ast.parse(""" ... x = "hello" ... """))) Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))]) >>> print(ast.dump(ast.parse(""" ... x = "he" "ll" "o" ... """))) Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))]) Nothing in the expression evaluator knows or cares about what kind of string literal you used, nor whether you included more than one. It's all just alternative forms of string literal. ChrisA