PyArg_Parse vs. PyArg_ParseTuple?
Dave Brueck
dbrueck at edgix.com
Mon Jan 29 12:09:32 EST 2001
> On Behalf Of Grant Edwards
> Subject: PyArg_Parse vs. PyArg_ParseTuple?
> I was hacking on socketmodule.c, and noticed that in some
> places PyArg_Parse() is used to convert Python data to C data,
> and in other spots PyArg_ParseTuple() is used.
>
> I found the documentation on PyArg_ParseTuple(), but I can't
> find any documentation on PyArg_Parse(). So I'm not 100% sure
> that what I did was "safe". What is the difference between
> PyArg_Parse and PyArg_ParseTuple?
Hi Grant,
I don't know for _sure_, but it seems like PyArg_Parse is the old style
while PyArg_ParseTuple is the new style of argument passing.
The context in which I remember it is with the PyMethodDef entry for
extension module functions. If the function's PyMethodDef entry has the
METH_VARARGS bit set then use PyArg_ParseTuple (since the PyObject it will
receive really will be a tuple), but with METH_OLDARGS (ie - no bit set) use
PyArg_Parse (the object might be None, an integer object, a string object,
etc).
Hopefully someone will correct me if I'm too far off..
-Dave
More information about the Python-list
mailing list