开发者

Trying to build a Python class in a C extension that can be instantiated from a Python module

I'm trying to build an exception class that I can use both in a C extension and the Python modules that import the extension. I'm using the PyErr_NewException to create the class as a superclass of the Exception class, but I can't figure out how to create an __init__ constructor for the class. I assume that is the best way to populate the class with t开发者_JS百科he attributes I need.


You should pass a dict as the third argument to PyErr_NewException. The dict should have an __init__ key bound to your initializer function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜