[Pyrex] [Cython-dev] kw-only arguments?

Stefan Behnel stefan_ml at behnel.de
Sun Sep 23 21:33:02 CEST 2007


Stefan Behnel wrote:
> Lenard Lindstrom wrote:
>> Greg Ewing wrote:
>>> Stefan Behnel wrote:
>>>
>>>   
>>>> is there a way to keep keyword arguments from taking a positional parameter?
>>>>     
>>> Only what you can currently do in Python, e.g.
>>>
>>>    def func(a, b, **kwds):
>>>      kw1 = kwds.pop('kw1')
>>>      kw2 = kwds.pop('kw2')
>>>
>>> I believe that keyword-only arguments are being
>>> considered for a future version of Python, and when
>>> that happens, I'll probably be updating Pyrex
>>> to match.
>>>
>>>   
>> PEP 3102 has been implemented for Python 3.0 .  No mention is made of a 
>> corresponding update to the C api.
> 
> Ah, thanks. I knew I read about that somewhere. I filed a bug report on Cython
> and I'll try to come up with an implementation.
> 
> https://bugs.launchpad.net/cython/+bug/144125

It's actually easier than I thought. Apart from the new syntax, all we have to
do is check that the positional arguments do not reach into the keywords, and
that required keywords are passed. Everything else is already taken care of.

Here's a patch that works for me, but I couldn't test everything yet. So if
someone wants to use it, I'd be glad to get some feedback. It should be
compliant with PEP 3102.

http://www.python.org/dev/peps/pep-3102/

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cython-pep3102-kwargs.patch
Type: text/x-diff
Size: 7683 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20070923/774ba369/attachment.bin 


More information about the Pyrex mailing list