newbie embedding questions

Will Ware wware at world.std.com
Thu Jan 6 17:11:50 EST 2000


Jason Maskell (backov at nospam.csolve.net) wrote:
> Well, I've finally gotten around to embedding Python in an app...
> The main app is essentially a skeleton, that will be driven by Python
> scripts.. It does however hold a bunch of C++ objects that it owns and
> instantiates and that the Python scripts need access to. So basically I need
> "glue" code to make sure the Python stuff has access to those instances'
> methods, and to set callbacks in the python code for generated events.

You might want to look at Swig (www.swig.org) which makes it really
painless to extend Python with C++ objects. I think the preferred
approach with C++ would be more extending than embedding, but from
your description of what you're doing, it sounds like this might
work for you. The only difference is that instead of writing a main()
function that calls the Python interpreter, you'll write a Python
script that imports the module produced by Swig.

I've done a few C and C++ extensions and had great luck. I have much
less experience with embedding and can't offer much insight about it.
If you're dead set on embedding, I would imagine Swig could still help
a lot, but I don't know the details of how you'd use it.
-- 
-----------------------------------+---------------------
 22nd century: Esperanto, geodesic | Will Ware
 domes, hovercrafts, metric system | wware at world.std.com



More information about the Python-list mailing list