[Python-ideas] keyword arguments everywhere (stdlib) - issue8706
Guido van Rossum
guido at python.org
Fri Mar 2 22:48:15 CET 2012
On Fri, Mar 2, 2012 at 1:09 PM, Arnaud Delobelle <arnodel at gmail.com> wrote:
> On 2 March 2012 20:00, Guido van Rossum <guido at python.org> wrote:
>> On Mar 2, 2012 11:43 AM, "Arnaud Delobelle" <arnodel at gmail.com> wrote:
>>> On 2 March 2012 19:28, Guido van Rossum <guido at python.org> wrote:
>
>>> > I would actually like to see a syntactic feature to state that an
>>> > argument *cannot* be given as a keyword argument (just as we already
>>> > added syntax to state that it *must* be a keyword).
>>>
>>> There was a discussion about this on this list in 2007. I wrote some
>>> decorators to implement it this functionality. Here's one at
>>>
>>>
>>> http://code.activestate.com/recipes/521874-functions-with-positional-only-arguments/?in=user-4059385
>>>
>>> (note that it didn't attract a lot of attention !). The recipe also
>>> refers to the original discussion.
>>
>> I've written such decorators too, but they've got quite a bit of overhead...
>
> The one in the above recipe (which is for 2.X) doesn't incur any
> runtime overhead - although it is a bit hackish as it changes the
> 'co_varnames' attribute of the function's code object.
So it's not written in Python -- it uses CPython specific hacks.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list