[Python-ideas] Positional only arguments

Tal Einat taleinat at gmail.com
Wed May 16 18:29:15 CEST 2007


On 5/16/07, George Sakkis <george.sakkis at gmail.com> wrote:
>
> This was posted on python-dev two weeks ago [1] but didn't get very
> far; probably python-ideas is a more appropriate list if this is to be
> taken any further.
>
> In short, PEP 3102 enables the declaration of keyword-only arguments,
> making it easier for an API to grow in a backwards compatible way. As
> Benji York, I see the utility of positional-only arguments, not just
> for the sake of symmetry but for pragmatic reasons; in fact the same
> reasons that serve as rationale to the keywords-only PEP.
>
> I don't have any concrete proposal (syntactic or otherwise) at this
> point, but I'd like to see this feature in Py3K even if I dislike the
> specific syntax or other machinery that implements it (just like
> decorators). For now it's worth just getting an idea of whether the
> feature itself is deemed useful enough or the current status quo is
> adequate.
>
> George
>
>
> [1] http://mail.python.org/pipermail/python-dev/2006-May/064790.html


Well, if the syntax currently suggested in PEP 3102 [1] is adopted:
def compare(a, b, *, key=None):

Then it could be decided that arguments before the asterisk are
positional-only, and those after the asterisk are keyword-only. This would
be backwards compatible, since functions defined without the asterisk could
work as they currently do.

Alternatively, we could decide that we don't like
positional-or-keyword-arguments at all any more, and do away with them
altogether. All arguments would be positional only by default, unless they
are declared keyword-only (by whatever syntax is adopted).

Now waiting for the big guys to knock this down :)

- Tal

[1] http://www.python.org/dev/peps/pep-3102/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20070516/cfab9337/attachment.html>


More information about the Python-ideas mailing list