PyModule_GetDict

Return the dictionary object that implements module’s namespace; this object is the same as the dict attribute of the module object.

import ExternalSensors
print(ExternalSensors.__dict__.keys())

PyDict_GetItemString

Return the object from dictionary p which has a key key.

Name

logger.debug(cv2.__name__)

PyImport_Import & PyImport_ImportModule

导入模块

pName = PyUnicode_DecodeFSDefault("UserScriptSample");
pModule = PyImport_Import(pName);
Py_DECREF(pName);

pModule = PyImport_ImportModule("UserScriptSample");

PyCallable_Check

检测一个PyObject对象是否可以调用,例如一个函数PyObject对象,使用该函数时返回1。

PyCallable_Check(pFunc)

PyObject_GetAttrString & PyObject_GetAttr

获取对象属性

pFunc = PyObject_GetAttrString(pModule, "multiply");

PyObject_CallObject

调用函数, 返回引用为New reference

pValue = PyObject_CallObject(pFunc, pArgs);

PyObject_CallMethod

调用对象的成员函数

PyObject* pFuncConfigureSensor = PyObject_CallMethod(PyInstanceExtSensor, "configureSensor", "O", funcArgs);