[capi-sig] Creating type object dynamically in run-time

Mateusz Loskot mateusz at loskot.net
Fri May 11 11:22:37 CEST 2012

On 10 May 2012 18:52, Stefan Behnel <python_capi at behnel.de> wrote:
> 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.

It makes perfect sense to me, thanks!

Best regards,
Mateusz Loskot, http://mateusz.loskot.net

More information about the capi-sig mailing list