By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

where to find the spec of format in PyObject_CallMethod

P: n/a
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.

Jan 10 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
Jan 10 '07 #2

P: n/a
Thanks. I have mixed arguments.

I found the format spec @ http://docs.python.org/api/arg-parsing.html

On Jan 10, 5:31 pm, Carsten Haese <cars...@uniqsys.comwrote:
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.Seehttp://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.
Jan 10 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.