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


Groups > comp.lang.python > #38889

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

Newsgroups comp.lang.python
Date 2013-02-14 14:01 -0800
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> <mailman.1779.1360868336.2939.python-list@python.org>
Subject Re: Suggested feature: slice syntax within tuples (or even more generally)?
From stephenwlin@gmail.com
Message-ID <mailman.1787.1360879302.2939.python-list@python.org> (permalink)

Show all headers | View raw


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

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