On Thu, Aug 19, 2010 at 8:35 PM, Greg Ewing wrote:
> Nick Coghlan wrote:
>
>> Or else it's just an accident of implementation, since the AST doesn't
>> actually *need* to distinguish those two cases.
>
> It doesn't seem to be an accident, because ast_for_slice()
> goes out of its way to manufactur
Nick Coghlan wrote:
Or else it's just an accident of implementation, since the AST doesn't
actually *need* to distinguish those two cases.
It doesn't seem to be an accident, because ast_for_slice()
goes out of its way to manufacture a Name node for the
missing argument.
It doesn't seem to sig
On Thu, Aug 19, 2010 at 6:36 PM, Greg Ewing wrote:
> In other words,
>
> x[::]
>
> is being parsed as though it had been written
>
> x[::None]
>
> Is there a good reason for an omitted third slice
> argument being treated differently from the others?
Probably so it looks different from the AS
I've discovered a slightly surprising thing about the way
AST objects for slices are constructed. According to
Python.asdl, all three parts of a slice are optional:
slice = Slice(expr? lower, expr? upper, expr? step)
But that's not quite the way the parser sees things:
Python 3.1.2 (r312:791