Hi Todd You wrote:
Why would that be the case? d[1:3] is allowed but d(1:3) isn't. The interpreter replaces "1:3" with "slice(1, 3)" behind-the-scenes.
>>> s ='hello' >>> s[1:3] 'el' >>> s[(1:3)] SyntaxError: invalid syntax >>> f(x=1:3) SyntaxError: invalid syntax My understanding is that the syntax errors arise because the parser is expecting, but not getting, an expression. (The conversion of "1:3" to a slice is semantics, not syntax.) My understanding is that if we make "1:3" an expression, as described in my previous post, then it will also follow that
{ :: :: :} is valid syntax.
To allow >>> d[x=1:3] while forbidding >>> { :: :: :} will I think require changes in several places to Python.asdl. I think it reasonable to require the PEP to explicitly state what those changes are. If not you then perhaps some supporter of this change can provide such changes, to be included in the PEP. By the way, Python.asdl is included verbatim in the docs page https://docs.python.org/3/library/ast.html#abstract-grammar https://github.com/python/cpython/blob/3.8/Doc/library/ast.rst#abstract-gram... -- Jonathan