我在 cython 中为 python 创建了一个 C++ 包装器。
C++ 类的方法名称为 makeBooleanValue,但在 python 中我希望等效方法为 make_boolean_value。
但我收到错误:
Traceback (most recent call last): File "saxon_example.py", line 7, in xdmAtomicval = proc.make_boolean_value(False) AttributeError: 'saxonc.PySaxonProcessor' object has no attribute 'make_boolean_value'
我似乎无法在 cython 中使用不同的命名约定。
在 pxd 文件中,我有以下内容:
XdmAtomicValue * makeBooleanValue(bool b)
在 pyx 文件中,我有以下内容:
def make_boolean_value(self, b): cdef bool c_b = b cdef PyXdmAtomicValue val = PyXdmAtomicValue() val.derivedaptr = val.derivedptr = val.thisvptr = self.thisptr.makeBooleanValue(c_b) return val
但是在我的 python 示例脚本中:
print(dir(library))
我得到 make makeBooleanValue
请问我缺少什么想法吗?
最佳答案
当我运行 python 脚本时,pyx 文件中的更改似乎没有被拾取。但是当我从命令行运行 python 时它就会被拾取
关于python - python 错误的 cython 包装器中的 AttributeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56237163/