[Python-ideas] Positional-only parameters

Ethan Furman ethan at stoneleaf.us
Thu Mar 2 03:57:35 EST 2017


On 03/01/2017 11:41 PM, Stephan Houben wrote:

> I have a slight variant of the decorator proposal.
> Rather than specify a count, let the decorator implement the typeshed dunder convention:
>
> @positional_only
>      def replace(self, __old, __new, count=-1):
>
> (I imagine this decorator would also treat "self" as position_only,
> so no need for __self.)
>
> Pros:
> 1. Consistent with the typeshed convention.

Only a pro if you like that convention.  ;)

> 2. Avoids a count.
> 3. Strictly opt-in, so hopefully keeps those @#?! underscore preservationists from picketing my lawn (again!).

Using a decorator is also strictly opt-in.

Oh, and did someone say it was time for the protest?

[----------------------]   [----------------------]
[                      ]   [                      ]
[ NO MORE UNDERSCORES! ]   [ NO MORE UNDERSCORES! ]
[                      ]   [                      ]
[----------------------]   [----------------------]
           | |                         | |
           | |                         | |
           | |                         | |
           | |                         | |
           |-|                         |-|

--
~Ethan~


More information about the Python-ideas mailing list