Re: embedding python

Guido.van.Rossum@cwi.nl
Tue, 13 Apr 1993 10:29:29 +0200

(This may be of general importance, hence the cc: to the list --Guido)

Quentin Fraser writes:

>There is good documentation for extending python, but only a brief mention
>of embedding it in other applications. Have I missed anything?

At the time I wrote that documentation it hadn't been done yet but the
code was designed to make it very simple.

>Are there guidelines for doing this?

Not yet. As it's so simple, they follow below...

>Have many people done it?

At least one company has done it (for a GUI builder), one university
(for a VR system), and one person in my building (for an OO multimedia
system). There may be more...

>Is it just a case of calling routines in pythonrun.h?

Basically, yes. If you look at pythonmain.c, you'll see in what order
things have to be initialized:

initargs(&argc, &argv);
initall();
setpythonargv(argc-optind, argv+optind);
/* optind is the index of the script name in argv */

After this you are free to call any of the run* functions or
call_object() any time you like (or anything else that's available to
extensions).

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>