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:79147, Aug 19 2010, 20:26:20) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> t = ast.parse("x[::]", mode='eval') >>> ast.dump(t) "Expression(body=Subscript(value=Name(id='x', ctx=Load()), slice=Slice(lower=None, upper=None, step=Name(id='None', ctx=Load())), ctx=Load()))" 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? -- Greg
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