How to define a new type (class) in Python using C API?
Posted
by ~mech
on Stack Overflow
See other posts from Stack Overflow
or by ~mech
Published on 2010-06-07T14:46:35Z
Indexed on
2010/06/07
15:02 UTC
Read the original article
Hit count: 168
Hi,
I am trying to use the Python C API to define a new class inside a module that would expose certain functionality written in C to Python code. I specifically want to have it in the form of a class and not a set of module functions.
However, I can't find anything regarding this particular task in the official documentation. The closest I could find is PyClass_New function (in the Python.h header) but it is not mentioned anywhere in the official docs, so I assume it is not supposed to be used.
So, what is the proper way to define a new Python class from C code?
Thanks.
© Stack Overflow or respective owner