Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sufficient': 0.05; 'expressions': 0.07; 'parser': 0.07; 'incorrect': 0.09; 'parsed': 0.09; 'to:addr:comp.lang.python': 0.09; 'warn': 0.09; 'cc:addr :python-list': 0.10; "'()'": 0.16; '2),': 0.16; 'literals:': 0.16; 'none),': 0.16; 'restricting': 0.16; 'sees': 0.16; 'subject:)?': 0.16; 'syntax.': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'cc:2**0': 0.23; 'statement': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'dictionary': 0.29; 'indentation': 0.29; 'relies': 0.29; 'thursday,': 0.30; 'expect': 0.31; 'could': 0.32; 'right?': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'next': 0.35; 'ability': 0.36; 'should': 0.36; 'subject: (': 0.36; 'level': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'where': 0.40; 'from:no real name:2**0': 0.60; 'within': 0.64; 'following.': 0.65; '2013': 0.84; 'loses': 0.84; 'received:209.85.216.184': 0.84 X-Received: by 10.49.1.43 with SMTP id 11mr15670qej.29.1360879299529; Thu, 14 Feb 2013 14:01:39 -0800 (PST) Newsgroups: comp.lang.python Date: Thu, 14 Feb 2013 14:01:39 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=74.108.115.166; posting-account=8IvmGwoAAADD6gKwJqZ9X0RQwAp81c9x References: <2e07acfb-4f48-4a27-9b06-3d8103325c0f@googlegroups.com> <511c9a66$0$11096$c3e8da3@news.astraweb.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 74.108.115.166 MIME-Version: 1.0 Subject: Re: Suggested feature: slice syntax within tuples (or even more generally)? From: stephenwlin@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: Python 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: , Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360879302 news.xs4all.nl 6862 [2001:888:2000:d::a6]:38840 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38889 On Thursday, February 14, 2013 1:58:06 PM UTC-5, Ian wrote: > > That's not ambiguous, because the former is simply invalid syntax. > > However, consider the following. > > > > if 1: 2: > > > > That could be either a one-line if statement where the condition is 1 > > and the body is slice(2, None), or it could be the beginning of a > > multi-line if block where the condition is slice(1, 2). If the parser > > sees that, should it expect the next line to be indented or not? If > > it relies on indentation to determine this, then it loses some ability > > to warn the user of incorrect indentation. > > > > Then we have dictionary literals: > > > > {1:2:3} > > > > Should that be read as dict([(slice(1, 2), 3)]) or dict([(1, slice(2, > > 3))])? Or even set([slice(1, 2, 3)])? > Restricting this to within the top level of ()-enclosed expressions would be sufficient to eliminate all ambiguities, though, right? Basically all that needs to change is for expressions within '()' to be parsed identically as are currently parsed in '[]'. -Stephen