[Python-ideas] Keyword-only arguments?
Philipp A.
flying-sheep at web.de
Sat Jun 20 20:13:46 CEST 2015
OK, i think it’s time to finally switch to python 3 instead of writing more
horrible crutches:
# coding: utf-8from __future__ import absolute_import, division,
print_function, unicode_literalsfrom builtins import *
import trolliusfrom trollius import From, Return
from other import stuff
@trollius.coroutine at modifiers.kwoargs('b')def awesome_stuff(a, b=5):
res = (yield From(stuff()))
raise Return(res)
vs.
import asyncio
from other import stuff
@asyncio.coroutinedef awesome_stuff(a, *, b=5):
res = (yield from stuff())
return res
or soon:
from other import stuff
async def awesome_stuff(a, *, b=5):
res = await stuff()
return res
Yann Kaiser kaiser.yann at gmail.com <http://mailto:kaiser.yann@gmail.com>
schrieb am Sa., 20. Juni 2015 um 19:52 Uhr:
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
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150620/d58afea3/attachment.html>
More information about the Python-ideas
mailing list