[Python-checkins] r42611 - python/trunk/Python/ast.c

Jeremy Hylton jeremy at alum.mit.edu
Tue Feb 28 03:57:52 CET 2006


I'm referring to the ambiguity noted in the language reference.

http://docs.python.org/ref/slicings.html

"There is ambiguity in the formal syntax here: anything that looks
like an expression list also looks like a slice list, so any
subscription can be interpreted as a slicing. Rather than further
complicating the syntax, this is disambiguated by defining that in
this case the interpretation as a subscription takes priority over the
interpretation as a slicing (this is the case if the slice list
contains no proper slice nor ellipses). Similarly, when the slice list
has exactly one short slice and no trailing comma, the interpretation
as a simple slicing takes priority over that as an extended slicing."

Jeremy

On 2/27/06, Guido van Rossum <guido at python.org> wrote:
> On 2/27/06, jeremy.hylton <python-checkins at python.org> wrote:
> > Author: jeremy.hylton
> > Date: Mon Feb 27 18:29:29 2006
> > New Revision: 42611
> >
> > Modified:
> >    python/trunk/Python/ast.c
> > Log:
> > Fix parsing of subscriptlist.
> >
> > (Armin's SF bug report).
> > d = {}
> > d[1,] = 1
> > Now handled correctly
> [...]
> > +            /* The grammar is ambiguous here. The ambiguity is resolved
> > +               by treating the sequence as a tuple literal if there are
> > +               no slice features.
> > +            */
>
> The grammar is not ambiguous. I don't understand the AST code well
> enough where the problem is/was, but there is no ambiguity in the
> parse tree.
>
> --
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>


More information about the Python-checkins mailing list