Python as an embedded scripting language

Alex Martelli aleaxit at yahoo.com
Wed Oct 4 06:23:03 EDT 2000


<lss at excosoft.se> wrote in message news:8ren1o$cq3$1 at nnrp1.deja.com...
> Is it possible to embed Python as a scripting language in a C++
> application and exposing the internals of the application to Python
> through use of dynamic extension modules (PYDs)? Or is it necessary to
> link the extension modules statically with the executable in order to
> give them access to its internal data, and thus also to link the Python
> interpreter in as well, since the extension modules must then be
> realized as builtin modules? This breaks PYDs altogether, though, since
> they are dependent upon a DLL Python core.

Your application can embed Python residing in a DLL, and add its
own modules to it with PyImport_AppendInittab (or the more general
PyImport_ExtendInittab) before it calls Py_Initialize.


> I would be thankful on any pointers on how to retain both Python's
> access to the application data structures and the ability to import
> PYDs.

Section 5.3 in "Python/C API Reference Manual".  For cross-platform
work, also note section 4.2 in "Extending and Embedding".


Alex






More information about the Python-list mailing list