More embedding questions

Dianne Hackborn (hackbod@newt.CS.ORST.EDU)
12 Feb 1995 06:02:09 GMT

Since the subject seems to have come up... :)

I am currently working on embedding Python into an application, and run
into a few questions:

First of all, is there any source on embedding Python other than the
"Extending Python" document? In particular, I am looking for some kind of
reference on all the available C functions; they are briefly mentioned in
the manual, but I can't find any kind of a complete list. I have had a
brief fling with the source code, but if there is any other place... :)

Second, the application needs to have multiple Python scripts running in
their own context. Not multi-threaded, but it may have multiple windows
open, each of which has a completely different Python script hooked into
its callbacks. It appears that I can supply explicate global and local
symbol tables when executing the scripts [assuming I can figure out which
functions to use and how to use them ;)], which I think would solve most of
the problems here. But I'm not sure about the builtin modules -- is it
okay to have different unrelated scripts using them? At first glance, it
appears that the only potential problem would be the 'sys' module; most of
the attributes there are okay since all the scripts will share stdin etc.,
and I could probably hack around to get things to work for the others...
but if there is any way to have something like an instantiation of sys for
each script...

And could there be any problems with this in any other modules? Do any
modules keep internal state variables that could cause independent scripts
to step on each other?

Third, is there any simple way to set things up so that the interpreter
will allow my program to keep a check on the scripts while they are
running? What I am thinking of is some kind of callback into my program it
can make when it checks for signals as per the sys.check_interval, so that
my program can check for some kind of user input to abort run-away scripts.

Thanks for any help with all this! :)

------------------------------------------------------------------------------
Dianne Kyra Hackborn "The single-child yuppo-family that uses the
hackbod@mail.cs.orst.edu child as a status object: ``A perfect child? Of
Oregon State University course! We have one here -- he's under the coffee
//www.cs.orst.edu/~hackbod/ table. Ralph, stand up! Play the violin!''" -- FZ