Comma is not always OK in the argument list?!

Nick Vatamaniuc vatamane at gmail.com
Sat Jul 29 18:36:26 EDT 2006


Dennis,

You make a good point, that is what I though first. Semantically I
thought a comma after **kw as in ..., **kw,) doesn't make sense because
there is nothing that could follow **kw except the ')'. But then trying
some other cases (see the previous posts for my examples) I noticed
that commas aren't allowed after *pos_args also. For example if ....,
*pos_args,) would be an error BUT stuff could follow *pos_args and that
could be **kw as in ..., *pos_args,**kw).

In other words the behavior is not consistent. So it seems that 3
things could happen with this:

1) Not allow commas after **kw only. Allow them in any other case,
because semantically 'stuff' could possibly follow.

2) Don't allow extra commas for all the argument lists. In other words
f(1,2,) or f(a=1,b=2,) would be an error.  But then do we want argument
lists to be consistent with tuples as far as syntax goes?

3) Allow trailing commas after all kinds of arguments in the argument
lists. This is what the documentation describes at the moment. I think
this is more sensible. I understand that argument lists and tuples are
not the same, but it would be nice to have a _syntactic_ consistency,
as opposed to 'a surprise'. As in t=(1,2,3,)  f(1,2,3,)  f(1,*[2,3],)
and f(1,*[2],**{'c':3},) should all be 'OK'.

Perhaps more Python core developers would comment...

Nick Vatamaniuc


Dennis Lee Bieber wrote:
> On 29 Jul 2006 07:26:57 -0700, "Nick Vatamaniuc" <vatamane at gmail.com>
> declaimed the following in comp.lang.python:
>
> > 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
>
> 	Part of the problem may be that the * notation implies that the
> associated argument is supposed to fill ALL other supplied positional
> arguments -- so what is that empty argument after the , supposed to be
> associated with? A positional argument /after/ all positional arguments?
> --
> 	Wulfraed	Dennis Lee Bieber		KD6MOG
> 	wlfraed at ix.netcom.com		wulfraed at bestiaria.com
> 		HTTP://wlfraed.home.netcom.com/
> 	(Bestiaria Support Staff:		web-asst at bestiaria.com)
> 		HTTP://www.bestiaria.com/




More information about the Python-list mailing list