Embedding

The Python interpreter can also be embedded into other applications. When embedding the interpreter on UNIX, you must include the file config.c (usually found in a place such as <python>/lib/python2.4/config/config.c, where <python> is the directory in which Python was installed) and link against the library libpython2.4.a. (A comparable but more complex process is required on Windows and the Macintosh. Consult the online documentation for details.)

The following functions are used to call the interpreter to execute code and control its operation:

						int PyRun_AnyFile(FILE
						*fp,
						char
						*filename)

If fp is an interactive device such as tty in Unix, this function calls PyRun_InteractiveLoop(). Otherwise, PyRun_SimpleFile() is called. filename ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.