embedded AND extended C code

Gordon McMillan gmcm at hypernet.com
Thu Aug 16 07:43:44 EDT 2001


Neil Macneale wrote: 

 
> I am calling Py_InitModule to load modules before, but I have only used
> it in functions that at were meant to extend python only. IE, in
> initmodule() functions. Now I am calling it from a C function of a
> program which embeds python. Basically, I am both embedding the
> interpreter in a C program, and I am extending the interpreter with C
> code. 

[snip]

> void init_treemaker(char * progName){
>     Py_SetProgramName(progName);
>     Py_Initialize();

[snip]

Know that horrid grinding noise when you try to start a car that's already 
running? That's what you've got here.

You can embed and extend from the same C program, but you have to embed 
first and extend later. See mcmillan-inc.com/embed2.html for a simplistic 
example.

- Gordon





More information about the Python-list mailing list