Please, someone tell me what's going wrong here. ;>

Jason Maskell backov at nospam.csolve.net
Tue Jan 11 19:59:10 EST 2000


Michael P. Reilly <arcege at shore.net> wrote in message
news:udQe4.3161$Ef6.805744 at news.shore.net...
> Jason Maskell <backov at nospam.csolve.net> wrote:
> I would try to stay away from calling the module initializers, they
> are designed with a purpose in mind.  Go for the documented route:
>
> void initxyzzy()
>   {
>     (void)Py_InitModule("xyzzy", xyzzy_methods);
>   }

Hmm, ok. ImportModule is in the embed demo, which is why it's in my code as
well. Removing it seems to have no effect, so it's gone. ;>

>
> void TForm1::Button1Click(TObject *Sender)
> {
>     int a;
>     Py_SetProgramName(Application->ExeName.c_str());
>     Py_Initialize();
>     a=PyRun_SimpleString("import xyzzy"); /* import into the namespace */
>     a=PyRun_SimpleString("xyzzy.foo()");
>     Py_Finalize();
> }
>
> The module never got imported into the __main__ module, only
> initialized.

Thank you thank you thank you! I was staying away from the import command,
as I mistakenly thought it would try to load a module called xyzzymodule.o
or something. I guess I need to read up the docs some more. Anyway, that's
shattered the last little barrier for me, I can proceed with my embedding. I
owe you a pint! ;>

Cheers,
Jason






More information about the Python-list mailing list