"str object is not callable" error
venkat sanaka
venkatsanaka at gmail.com
Wed Apr 8 17:11:37 EDT 2009
HIi everyone.
i was using python/c api to call a python function from c and I know the
name of the function which i want to call.Is there any way to do that??
This is the method i tried...
for eg:This is the python function i wants to call.
>>>def add(x):
... return x+10
This is my code in C:
PyObject *result = NULL;
int arg;
PyObject *arglist;
arg = 123;
my_callback = "add";
arglist = Py_BuildValue("(i)", arg);
result = PyObject_CallObject(my_callback, arglist);
Py_DECREF(arglist);
return result;
I was getting a error like "str object is not callable".From the error i
came to know that i was assigning "add" as a string which caused this
error.Then how to make it a callable object??
Regards
Venkat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090409/e6b6d770/attachment.html>
More information about the Python-list
mailing list