If I want to get a PyObject
for something like, say, sys.exc_info
, I can write
PyObject *sys_module = PyImport_Import("sys");
PyObject *sys_exc_info = PyObject_GetAttr(sys_module, "exc_info");
What if I want to get a PyObject
corresponding to a builtin such as list()
or dir()
? I've tried writing PyImport_Import("builtins")
and PyImport_AddModule("builtins")
and looking in the dictionary for that module, but it doesn't seem to be working as expected.
builtins
在 Python 2 中称为__builtin__
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.