[capi-sig] Creating type object dynamically in run-time
python_capi at behnel.de
Thu May 10 19:52:27 CEST 2012
Mateusz Loskot, 10.05.2012 19:13:
> On 10 May 2012 17:39, Stefan Behnel wrote:
>> What you'd do next is to initialise your types in the module (or let
>> CPython do it for you through the inittab)
> I'm not sure I completely understand it.
> I assume that executing these two lines,
> in context of the module:
> const char* c = "class A(object):\n\tpass";
> PyRun_StringFlags(c, Py_file_input, d, d, NULL);
> creates complete and initialised A class within this module.
> Doesn't it?
Yes, it does. What I meant what: if you want to let the dynamically
generated Python classes inherit from your extension types, then initialise
the extension types before hand so that they turn up in the module dict and
your Python code can use them normally as base types.
More information about the capi-sig