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


Groups > comp.lang.python > #38878

Re: Suggested feature: slice syntax within tuples (or even more generally)?

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 <ian.g.kelly@gmail.com>
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> <mailman.1754.1360819410.2939.python-list@python.org> <mailman.1756.1360821290.2939.python-list@python.org> <511c9a66$0$11096$c3e8da3@news.astraweb.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 14 Feb 2013 11:58:06 -0700
Subject Re: Suggested feature: slice syntax within tuples (or even more generally)?
To Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1779.1360868336.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Thu, Feb 14, 2013 at 1:03 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> 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)])?

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


Thread

Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 11:00 -0800
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Terry Reedy <tjreedy@udel.edu> - 2013-02-14 00:23 -0500
    Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 21:54 -0800
    Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 21:54 -0800
      Re: Suggested feature: slice syntax within tuples (or even more generally)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-14 07:32 +0000
        Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 00:36 -0800
      Re: Suggested feature: slice syntax within tuples (or even more generally)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-14 08:03 +0000
        Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 01:08 -0800
          Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 01:26 -0800
        Re: Suggested feature: slice syntax within tuples (or even more generally)? Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-14 11:58 -0700
          Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 14:01 -0800
          Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 14:01 -0800
            Re: Suggested feature: slice syntax within tuples (or even more generally)? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-14 17:46 -0800
            Re: Suggested feature: slice syntax within tuples (or even more generally)? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-14 17:46 -0800
  Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 22:06 -0800
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Duncan Booth <duncan.booth@invalid.invalid> - 2013-02-14 12:25 +0000
    Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 07:56 -0800
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Andrew Robinson <andrew3@r3dsolutions.com> - 2013-02-25 01:10 +0000
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-25 03:28 -0700
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Terry Reedy <tjreedy@udel.edu> - 2013-02-25 06:23 -0500
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-25 09:54 -0700
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Andrew Robinson <andrew3@r3dsolutions.com> - 2013-02-25 09:47 +0000
  Re: Suggested feature: slice syntax within tuples (or even more generally)? Nobody <nobody@nowhere.com> - 2013-02-26 07:38 +0000

csiph-web