[Python-ideas] Keyword-only arguments?

Philipp A. flying-sheep at web.de
Sat Jun 20 21:05:52 CEST 2015


sure! and having those workarounds if you really need them is great.

it’s just really frustrating that so many of you are stuck with 2.7 or even
less without more reason than “sysadmin won’t install a SCL”.

Yann Kaiser <kaiser.yann at gmail.com> schrieb am Sa., 20. Juni 2015 um
20:28 Uhr:

> Definitely agree with wanting to move on and focus on Python 3.
>
> I design my stuff with Python 3 first in mind, but reality tells me I need
> to keep supporting Python 2 users, even if that means uglifying front-page
> examples with things such as sigtools.modifiers.kwoargs. The existence of
> this thread and of some of the emails in the "signature documentation"
> thread only serves as proof that I'd confuse too many by keeping "kwoargs"
> & co a side-note.
>
> Developing on Python 3.4 is great, things like chained tracebacks are
> fantastic. If I can do it on Python 3, I will. But what if I want to deploy
> to GAE? Stuck with 2.7. So are many users.
>
> It's ugly, it sucks, but so far it is out of my hands and necessary.
>
> On Sat, 20 Jun 2015 at 20:13 Philipp A. <flying-sheep at web.de> wrote:
>
>> 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/80a468b0/attachment.html>


More information about the Python-ideas mailing list