Tricky interpreter initialization question..

Jason Maskell backov at nospam.csolve.net
Mon Jan 10 14:37:42 EST 2000


Ok, in the past I've been asking a few questions about embedding.. After
reading the responses and continuing research, I was somewhat stumped.. But
now I've gotten to the point in my project where getting Python embedded is
pretty much necessary. So, some questions:

I have a running application, with lots of objects that Python needs access
to, so here's what I think I can do (but am not quite sure how to do it):

Start up my app.

Initialize the Python interpreter and then call one or a series of init
procedures that calls Py_InitModule(), without having used "import spam" to
create the module object. Can I get this to work?

Here's my reasoning:

I don't have any code (.o or .lib) to provide to an import function. I don't
see how I could use import as it's supposed to reference code that's already
running, not that the python interpreter runs itself.

I don't want to shove my skeleton into a .dll and thus "extend" Python.
That's just too messy to even contemplate.

I figure it should be possible to initialize these modules at run-time and
thus get around the first two problems. Writing the glue code isn't a
hardship, but again, the interpreter needs to be pointed to already
instantiated interfaces, not stuff it has to instantiate itself.

Any help?

Cheers,
Jason






More information about the Python-list mailing list