On Mon, Feb 2, 2015 at 1:48 PM, Paul Moore <p.f.moore@gmail.com> wrote:
On 2 February 2015 at 10:22, Todd <toddrjen@gmail.com> wrote:
> Let's just call this a range literal.  It has some features similar to
> slices, but not all.

So what would d[1:10:2] mean? d[Slice(1,10,2)] or d[range(1,10,2)]?

At the moment 1:10:2 is a slice literal, and you're proposing to
repurpose it as a range literal? What have I missed? Because that's
never going to satisfy backward compatibility requirements.


No, I am proposing that (x:y:x) is syntactic sugar for range(x, y, z).  Note the parentheses.  Currently wrapping slice notation in a parentheses is not valid syntax, so there is no backwards-compatibility issues.  Bare slice notation, without the parentheses or in an index, will remain invalid syntax.

I am absolutely not proposing that anything change with existing slices.  d[1:10:2] would not change at all.  d[(1:10:2)] would become valid syntax, but it is not the use-case that prompted it and I doubt anyone would actually want to do that. 

I am more interested in something like:

for i in (1:10:2):
   pass

I am also not proposed the following syntax, since it would be ambiguous in many cases:

for i in 1:10:2:
   pass