Comma is not always OK in the argument list?!

Nick Vatamaniuc vatamane at gmail.com
Sat Jul 29 10:26:57 EDT 2006


Roman,

The way  I see it, it could be either way. In other words if I can
write f(1,2,3) and f(1,2,3,) I should also be able to write
f(1,*[2,3],). It is a really small detail but there sould be some
consistency. Either no extra commas for all kinds of argument types or
extra commas for _all_ of them. It seems though also that if it is
possible to do it with lists, tuples and dictionaries, it should also
be possible to do it with argument lists. In other words if (1,2,3,)
makes sense so should func(1,2,3,) even when written as
func(1,2,*[3],).

Well you are the one who discovered this so you shoud be the one
submitting the bug report! Here is PEP 3 page with the guidelines for
bug reporting:
http://www.python.org/dev/peps/pep-0003/

Just mark it as a very low priority since it is more of a cosmetic bug
than a serious showstopper.

-Nick V


Roman Susi wrote:
> 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