How to get the Callable of builtin functions

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


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.


More information about the Python-list mailing list