c++ - 嵌入 Python : How to help the scripter?

标签 c++ python boost boost-python

我正在使用 Boost 将 Python 嵌入到我的应用程序中。例如,我想检查以下函数是否接收一个整数和一个字符串作为第一个和第二个参数(该函数是在 C++ 中定义的)。

someFunction(123, 'words')

如果我发现参数不正确,我该如何通知脚本编写者他们需要更正哪一行?

最佳答案

如果您使用通常的 def("someFunction",someFunction,...) 包装函数,调用者将自动收到有关无法匹配的 c++ 签名的通知使用从 python 传递的对象,像这样(该方法采用一个字典参数,而是用 3 个数字调用):

>>> scene.updateAttrs(1,2,3)

ArgumentError: Python argument types in
    Serializable.updateAttrs(Scene, int, int, int)
did not match C++ signature:
    updateAttrs(Serializable {lvalue}, boost::python::dict)

你能发布一些代码看看你的问题是什么吗?

关于c++ - 嵌入 Python : How to help the scripter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6939711/

相关文章:

c++ - boost::transform_iterator 不适用于 std::bind( &Pair::first, _1 )?

c++ - registerPointPickingCallback (PCLViewer::callback_Test,(void*)&viewer);返回 C3687 非标准语法;使用 '&' 创建指向成员的指针

C++容器问题

c++ - 如何在 C++ 中使用 Sobol 序列生成分布良好的正态分布?

c++ - 是否可以在模板特化中匹配模板化基础?

c++ - 函数不是全局命名空间的成员

python - 为什么 find_all BeautifulSoup4 函数没有返回任何内容?

c++ - Map数据结构困惑的Map

计算数组偏移量的 Pythonic 方法

python - 在Python中以不同的步骤转移数据