How to get the Callable of builtin functions

Janet zptang at hotmail.com
Wed Sep 26 23:10:54 CEST 2001


Hi,

This question is about embedding Python in C.
Does anyone know how to obtain a callable PyObject of the system
built-in functions, like "print" and "exec"?
I tried:
PyObject *m = PyImport_AddModule(__main__);
PyObject *func = PyObject_GetAttrString(m, "print");

but the 2nd function failed, returning NULL.

Thanks



More information about the Python-list mailing list