On Thu, Aug 19, 2010 at 6:36 PM, Greg Ewing <[email protected]> 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 AST for x[:]
>>> ast.dump(ast.parse("x[:]", mode='eval'))
"Expression(body=Subscript(value=Name(id='x', ctx=Load()),
slice=Slice(lower=None, upper=None, step=None), ctx=Load()))"
>>> ast.dump(ast.parse("x[::]", mode='eval'))
"Expression(body=Subscript(value=Name(id='x', ctx=Load()),
slice=Slice(lower=None, upper=None, step=Name(id='None', ctx=Load())),
ctx=Load()))"
Or else it's just an accident of implementation, since the AST doesn't
actually *need* to distinguish those two cases.
Cheers,
Nick.
--
Nick Coghlan | [email protected] | Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com