where to find the spec of format in PyObject_CallMethod

Carsten Haese carsten at uniqsys.com
Wed Jan 10 23:31:19 CET 2007


On Wed, 2007-01-10 at 14:05 -0800, Huayang Xia wrote:
> I am trying to use PyObject_CallMethod. It needs a format string to
> specify what are the followed arguments. Is it possible to use a
> PyObject* as an argument?
> 
> Where can I find the spec for the format?
> 
> Thanks in advance.

See http://docs.python.org/api/object.html#l2h-247 :

Note in particular "The C arguments are described by a Py_BuildValue()
format string that should produce a tuple" and "Note that if you only
pass PyObject * args, PyObject_CallMethodObjArgs is a faster
alternative."

So, If all your arguments are PyObject pointers, use
PyObject_CallMethodObjArgs instead. Otherwise, use PyObject_CallMethod
and consult the documentation for Py_BuildValue on how to construct the
format string.

Hope this helps,

Carsten.





More information about the Python-list mailing list