On Thu, Aug 19, 2010 at 6:36 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> 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 | ncoghlan at gmail.com | Brisbane, Australia
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4