Comma is not always OK in the argument list?!

olsongt at verizon.net olsongt at verizon.net
Fri Jul 28 09:15:48 EDT 2006


Nick Vatamaniuc wrote:
> Roman,
>
> According to the Python call syntax definition
> (http://docs.python.org/ref/calls.html) commas should be allowed, so it
> seems like a minor bug.  Here are the  lines in question:
> -----http://docs.python.org/ref/calls.html-----------
> call ::= primary "(" [argument_list [","]] ")"
> argument_list::=positional_arguments ["," keyword_arguments] ["," "*"
> expression] ["," "**" expression]
> 	| keyword_arguments ["," "*" expression] ["," "**" expression]
>         | "*" expression ["," "**" expression]
>         | "**" expression
> ----------------------------------------------------------
> If you notice in the 'call' definition, no matter what the
> 'argument_list' is, it can be followed by an optional ',' right before
> the closing ')'. Your code is a counterexample to this. Here is a more
> exhaustive example:
> --------------------------------------------------------

Actually, in the real BNF it's not allowed:

http://svn.python.org/view/python/trunk/Grammar/Grammar?rev=46209&view=markup

parameters: '(' [varargslist] ')'
varargslist: ((fpdef ['=' test] ',')*
              ('*' NAME [',' '**' NAME] | '**' NAME) |
              fpdef ['=' test] (',' fpdef ['=' test])* [','])
fpdef: NAME | '(' fplist ')'




More information about the Python-list mailing list