[Python-Dev] PEP 362 Third Revision

Nick Coghlan ncoghlan at gmail.com
Fri Jun 15 01:16:42 CEST 2012


On Jun 15, 2012 8:37 AM, "Benjamin Peterson" <benjamin at python.org> wrote:
>
> 2012/6/14 Nick Coghlan <ncoghlan at gmail.com>:
> > I like the idea of a kind attribute, I don't like the current names for
the
> > possible values.
> >
> > At the very least, "positional only" needs to be supported to handle
> > nameless parameters in C functions (or those that unpack *args
internally)
> >
> > The level of abbreviation used also seems unnecessary and internally
> > inconsistent.
> >
> > My proposal:
> > POSITIONAL- positional only
> > NAMED_POSITIONAL - normal parameter
>
> Probably POSITIONAL should be the normal one, and there should be
> ONLY_POSITIONAL for the weirdos.

I did think about that, but it's both inaccurate and internally
inconsistent without further changes.

Normal parameters can be specified by index (as a positional argument) or
by name (as a keyword argument). Thus, the distinctions to be made are
between "positional only", "positional or keyword" and "keyword only". If
positional only parameters are allowed to have names for documentation
purposes (as I believe they should), then using the "positional" kind for
the "positional or keyword" case is just plain wrong.

In addition, if the "only" isn't considered implied in the positional case,
then it can't be implied in the keyword case, either. That gives the other
set of internally consistent names I thought of:
POSITIONAL_ONLY
POSITIONAL_OR_KEYWORD
VAR_POSITIONAL
KEYWORD_ONLY
VAR_KEYWORD

I slightly prefer the first set I posted, but would be fine with this more
explicit approach, too.

Cheers,
Nick.

--
Sent from my phone, thus the relative brevity :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120615/895a493b/attachment.html>


More information about the Python-Dev mailing list