Craig Ringer wrote: > 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...
Lib/exceptions.c contains C code that creates class objects, and populates them with methods. make a copy and hack it until it suits your needs... </F> -- http://mail.python.org/mailman/listinfo/python-list