Comma is not always OK in the argument list?!

Roman Susi rnd at onego.ru
Sat Jul 29 08:03:43 EDT 2006


Nick Vatamaniuc wrote:

>True, that is why it behaves the way it does, but which way is the
>correct way? i.e. does the code need updating or the documentation?
>
>  
>
Perhaps, someone can make a bug report... IMHO, docs are wrong.

-Roman

>-Nick V.
>
>olsongt at verizon.net wrote:
>  
>
>>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