Chapter 8. Simple use of the embedded Python interpreter

Table of Contents
Motivation
Theory
Example

The Python interpreter doesn't just provide the run-time environment from which you can use Python objects and the Python/C API. It also allows the embedding program to execute arbitrary pieces of Python code from within the embedding program, a useful feature which can simplify Python object creation and manipulation.

Motivation

The PYTHON_OBJECT class hierarchy provides an elegant way to use Python primitives from within Eiffel, and does so with a good degree of success. However, this is not the only way to use Python from within Eiffel--far from it! What if the software developer wishes to execute arbitrary snippets of Python code from within the embedding program, or use the Python interpreter interactively as a sort of "interactive console" with the developed application? The Python/C API, exposed via the PYTHON_CLIENT class, provides a few functions to let us do just that.