[Python-ideas] Positional-only parameters

אלעזר elazarg at gmail.com
Wed Mar 1 17:16:47 EST 2017


On Wed, Mar 1, 2017 at 9:26 PM Serhiy Storchaka <storchaka at gmail.com> wrote:

> On 28.02.17 23:17, Victor Stinner wrote:
> > My question is: would it make sense to implement this feature in
> > Python directly? If yes, what should be the syntax? Use "/" marker?
> > Use the @positional() decorator?
>
> <snip>


> The problem with the "/" marker is that it looks ugly. There was an
> excuse for the "*" marker -- it came from omitting the name in "*args".
> The "*" prefix itself means an iterable unpacking, but "/" is not used
> neither as prefix nor suffix.
>

I like the idea, but I wanted to note that since it has no meaning from the
point of view of the defined function, it can be done with a magic
decorator, so new syntax is not required:

@positional_only[:4]
def replace(self, old, new, count=-1):
    ...

It may ease googling and backporting, by defining positional_only[slice] to
be the identity function.

Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170301/12fb73bf/attachment.html>


More information about the Python-ideas mailing list