On Thu, Jun 5, 2008 at 7:02 PM, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Alexandre Vassalotti wrote: >> Is there a way to specify keyword-only arguments using the C API. I >> searched through the mailing list archive, read PEP 3102 and grep-ed >> the codebase, but I found nothing looking like a C API. So I am >> wondering, is this a Python-only feature? > > The C API has had this for a long time, but only in the *args, **kwds form - > i.e., an argument is keyword only if the C code only looks for it in the > keywords dictionary and not the args tuple. > > There's no special support for it in the arg parsing machinery that I know > of, if that's the question you're asking.
I believe Alexandre is familiar with PyArg_ParseTupleAndKeywords(), but its API doesn't let you specify keywords that have no positional equivalent. He's after the C equivalent of def foo(*, a, b): ... where a and b *must* be specified as keywords by the caller. I don't believe this is supported, due to the way PyArg_ParseTupleAndKeywords() and friends are implemented. I don't think it's a great loss, but if someone has the urge to implement an API with an even longer name that supports this, I won't stop them. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com