Writing class factories with the Python/C API?

C

Craig Ringer

Hi folks

I'm currently faced with the need to write a class factory in C using
the Python/C API. It's purpose is to automatically wrap C++ objects at
run-time and provide a Python object. Thanks to the magic of Qt's
meta-object system, getting the information required to wrap the C++
object is the easy bit.

What I'm not sure I can do is create 'built-in' Python classes at run
time. I don't need to create classes in response to calls from Python
code, only C code, but the newly created classes do need to be available
to Python code of course. The newly created classes will be fairly
simple subclasses of a more powerful parent, and all they really need to
do is implement a bunch of methods and

So, before I throw myself too deeply into this task, does this sound
like something that's vaguely practical? All I'll really need to do is
add a bunch of methods on the generated subclasses, so I'm hoping so...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top