where to find the spec of format in PyObject_CallMethod

H

Huayang Xia

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.
 
C

Carsten Haese

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top