Re: About the grammar

2010-04-19 Thread franck
> >     argument: ... | test '=' test > Where are you finding that? This comes from Python-2.6/Grammar/Grammar in the source distribution. > This tells you that keyword arguments cannot have keywords that aren't > identifiers: > > >>> sum(1=2) > >   File "", line 1 > SyntaxError: keyword can't be

Re: About the grammar

2010-04-19 Thread franck
Thank you for this very clear (and quick) explanation! :-) Cheers, Franck On 19 avr, 08:58, "Martin v. Loewis" wrote: > # The reason that keywords are test nodes instead of NAME is that using > # NAME results in an ambiguity. ast.c makes sure it's a NAME. > argument: test [comp_for] | test '='

Re: About the grammar

2010-04-19 Thread Martin v. Loewis
> Does any one knows why the grammar is so coded? Any intuition? The 2.7 Grammar clarifies that: # The reason that keywords are test nodes instead of NAME is that using # NAME results in an ambiguity. ast.c makes sure it's a NAME. argument: test [comp_for] | test '=' test The ambiguity is this:

Re: About the grammar

2010-04-18 Thread Steven D'Aprano
On Sun, 18 Apr 2010 23:29:44 -0700, franck wrote: > Dear all, > > I'm wondering why in Python's grammar, keyword arguments are specified > as: > > argument: ... | test '=' test Where are you finding that? > I would have expected something like > > argument: ... | NAME '=' test > >

About the grammar

2010-04-18 Thread franck
Dear all, I'm wondering why in Python's grammar, keyword arguments are specified as: argument: ... | test '=' test I would have expected something like argument: ... | NAME '=' test Indeed, I cannot imagine a case where the keyword is something else than an identifier. Moreover, in the