Hello, > I am using the below C code so that i can embed a Python Code and > get input from a python function and use it in C code . > > Below is the C Code [snipped]
> I am getting error > > AttributeError: 'module' object has no attribute 'print' > Cannot find function "print" How do you run your program (I suspect with 'pr pr print 1', should be 'pr pr pr 1'). FWIW, the following simplified program works: #include <Python.h> int main(int argc, char *argv[]) { PyObject *modname, *module, *args, *value, *func; Py_Initialize(); PyRun_SimpleString("import sys; sys.path.append(\".\")"); modname = PyString_FromString("pr"); module = PyImport_Import(modname); Py_DECREF(modname); if (NULL == module) { fprintf(stderr, "error: can't load\n"); Py_Finalize(); return 1; } func = PyObject_GetAttrString(module, "pr"); args = PyTuple_New(1); value = PyLong_FromLong(10); PyTuple_SetItem(args, 0, value); PyObject_CallObject(func, args); Py_Finalize(); return 0; } HTH, -- Miki <[EMAIL PROTECTED]> http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list