Instantiate a python class object in C

Dids didierblanchard at gmail.com
Wed Mar 14 09:46:01 EDT 2012


Hi,

Apologies if this was asked before, I couldn't find anything.

I have a class defined in a python file:
for example:

class demo:
      [ class definition goes here]

I'm writing a C extension.
In the first function, I take an instance of the "demo" class and do
my magic. It's working, all is good.

What I can't figure out is how to create a second C function that
returns a new instance to the "demo" class to python.
There must a be tutorial somewhere, but I can't find anything. I do
not want to define a new python class in C.

Another example:
   This is working:
        demo_obj1 = demo()
        my_C_extension.function_1( demo_obj1 )  //working, all good.

   This I can't figure out how to do:
        new_demo_obj = my_C_extension.function_2()

Thanks for reading,
Dids,



More information about the Python-list mailing list