Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'none,': 0.05; 'parser': 0.07; '"if': 0.09; 'incorrect': 0.09; 'warn': 0.09; '2),': 0.16; 'literals:': 0.16; 'none),': 0.16; 'sees': 0.16; 'subject:)?': 0.16; 'syntax.': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'feb': 0.19; 'statement': 0.23; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'colon': 0.29; "d'aprano": 0.29; 'dictionary': 0.29; 'indentation': 0.29; 'relies': 0.29; 'steven': 0.29; 'expect': 0.31; 'could': 0.32; 'to:addr:python-list': 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; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'following.': 0.65; '2013': 0.84; 'loses': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=9NPns4+/0kT3NqU5FmCFrhbEk4zlsUAhX2KUFVOgk0k=; b=N8s1qtOz0MkU9VBL2g/X7IOdBFp6kSUrQLPijWQPHGkosCvNItqfT6GUVWspo+fOH6 Y7htqnBxnPsTHiwXZ7nUEUJ7jNhY/e84ijYC7lq7X6ZZKQgkkKRcMuJ7NccrkDrMOZ7/ VjbAHbulCKsFhv5+oa5cwZ1veY0iYJU0OPamjGqHxx26wVY1fBfOQvVF1hPnBvgkL02M CsWpiDZ7fjwjjo9gI16tUeWf6cTsA4kojEoPkbxcVEHr0jvVmePioWsheugku4iYPWYX 47Y2O0iJsV7Chj1yEzx+ls94sbnhkocDFYLfzHKxbNSeJ5+Tyg8Q7slSHafMU4sDSH0+ +QiA== X-Received: by 10.68.251.167 with SMTP id zl7mr6762642pbc.116.1360868326990; Thu, 14 Feb 2013 10:58:46 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <511c9a66$0$11096$c3e8da3@news.astraweb.com> References: <2e07acfb-4f48-4a27-9b06-3d8103325c0f@googlegroups.com> <511c9a66$0$11096$c3e8da3@news.astraweb.com> From: Ian Kelly Date: Thu, 14 Feb 2013 11:58:06 -0700 Subject: Re: Suggested feature: slice syntax within tuples (or even more generally)? To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360868336 news.xs4all.nl 6848 [2001:888:2000:d::a6]:37571 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38878 On Thu, Feb 14, 2013 at 1:03 AM, Steven D'Aprano wrote: > E.g.: > > if x: > pass > > > Is that intended as "if slice(x, None, None)" with a missing colon, or > "if x" with colon supplied? 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)])?