【发布时间】:2012-11-21 11:46:30
【问题描述】:
我们可以提取一个指向 python 方法的 PyObject 使用
PyObject *method = PyDict_GetItemString(methodsDictionary,methodName.c_str());
我想知道该方法需要多少个参数。所以如果函数是
def f(x,y):
return x+y
我如何知道它需要 2 个参数?
【问题讨论】:
-
另外,刚刚注意到那里的
.c_str()- 所以我猜你正在使用C++。你看过 Boost.Python 或其他包装库吗? - 使用原生 Python C-API 不是最愉快的体验
标签: python python-c-api pyobject