Python/C API
Rainer Deyke
root at rainerdeyke.com
Thu Oct 5 17:10:01 EDT 2000
"Joerg Baumann" <joerg.baumann at stud.informatik.uni-erlangen.de> wrote in
message news:39DCC9F3.C9816CBA at stud.informatik.uni-erlangen.de...
> Thank you for your hints.
> This workes for me:
>
> a=PyImport_AddModule("xyz");
> b=PyModule_GetDict(a);
> // no Py_DECREF(a)
> a=PyDict_GetItemString(b,"foo");
> // no Py_DECREF(b)
> b=Py_BuildValue("(s)",_ptemp);
> c=PyObject_CallObject(a, b);
> Py_DECREF(b);
> // c holds xyz.foo("test") with refcount 1
An even simpler solution would be to do a PyObject_CallMethod on the module
itself.
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list