Chapter 12. Scripting Eiffel with Python

Table of Contents
Why a custom interpreter?
The scripting_eiffel sample program
Creating a custom Python interpreter to solve the "two binaries" problem

We are now able to call Eiffel features from within Python, using shadow classes, but at a cost--we must maintain two binaries: one for the shared library used in the Python module, and one for the application proper. An arguably better solution lies in embedding the Eiffel run-time environment entirely in Python by creating a custom interpreter and running the entire program as a Python script.


The example program in the last chapter did an adequate job of running Eiffel code entirely from within Python. Unfortunately, it did so at a peculiar cost--the Eiffel code for the scripted classes had to be duplicated in a shared module separate from the application proper, resulting in wasted space and the added problem of ensuring that the two remained synchronized. While these aren't crippling problems, it would be much easier to have a single binary. It would be even more interesting if the shell of the program itself was written in Python--in other words, we could realize the vision of tightly-written, well-constructed binary Eiffel components scripted with the easy-to-use, dynamic language Python--a worthy goal, but requiring a touch more effort.