PyArg_NoArgs / PyArg_Parse API

bdupire at seatech.fau.edu.bbs bdupire at seatech.fau.edu.bbs
Mon Jul 17 02:00:01 EDT 2000


Benoit Dupire wrote:

> PyArgs_NoArg(args) is an API function, used in timemodule.c and not
> referenced in the documentation..
>
> Actually, it's defined as a macro in Python.h
> and is equivalent to PyArg_Parse(args,"")
>
> I didn't see Py_ArgParse in the doc either!

OK I finally find out the answer. Thanks Mark, for your "programming Python"
book!
PyArg_Parse:
takes an object, a format string, and C targets. (like PyArg_ParseTuple)
But PyArg_Parse doesn't expect the Python object to be a tuple. We need to
supply () pairs in the format string to extract parts of returned tuples.

PyArg_Parse is also backward compatible with an older conversion variant
(getargs)
If the third column in a module's name/function  registration table is zero
(or absent), Python passes argument lists using old-style getargs
conventions : the argument list might not be a tuple, so PyArg_Parse is used
to extract values.
But normally the third column in a module's name/function registration task
should be 1, and PyArg_ParseTuple should be used for argument list
conversions

Benoit! :-)



More information about the Python-list mailing list