[Python-ideas] Keyword-only arguments?

Yann Kaiser kaiser.yann at gmail.com
Sat Jun 20 19:52:03 CEST 2015


On Wed, 17 Jun 2015 at 21:33 Nathaniel Smith <njs at pobox.com> wrote:

> there's really no good way to accomplish kw only args in py2. It can be
> done, but it's very cumbersome; not like range or print or whatever where
> you can just import something from six or add some parentheses.
>
As you correctly point out, it can't be done without friction.

I've attempted backporting kw-only parameters through decorators:

from sigtools import modifiers

@modifiers.kwoargs('kwop')
def func(abc, kwop):
    ...

@modifiers.autokwoargs
def func(abc, kwop=False):
    ...

http://sigtools.readthedocs.org/en/latest/#sigtools.modifiers.kwoargs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150620/efca1acd/attachment.html>


More information about the Python-ideas mailing list