Embedding as scripting engine

Doug Tolton dtolton at yahoo.com
Tue Jul 8 13:21:54 EDT 2003


There are a couple of sources of information.  Mark Hammond & Andy
Robinsons book "Python Programming on Win32" has an excelent section
on Dynamic Code Evaluation.  This is in Chapter 8 Adding a Macro
language.

They also mention that there is a com server included with PythonWin
that is located at Python\win32com\servers\interp.py.  This is a
python interpreter that can be bolted onto any com server.

If you are using a unix platform, you obviously won't be able to use
com, but the basic concepts will still be the same.  You will need to
use Eval and Exec for dynamic code evaluation.

Good Luck

Doug Tolton

On 8 Jul 2003 03:50:55 -0700, theincredibleulk at hotmail.com (Úlfur
Kristjánsson) wrote:

>Python... a great language, no doubt. And the abillity to be able to
>extend it with C/C++ code, fantastic. But has anybody been able to
>successfully embed Python in their application to use it as a
>scripting language of sorts?
>
>I am in the process of writing a game and from the documentation and
>word of mouth gathered that Python would be just the thing for the
>scripting part. And sure enough it is easy enough to run Python code
>from C/C++. However, in order to be make it do something actually
>useful for my game it would be handy to be able to pass in anything
>besides the basic data types (strings, numerics) such as either an
>instance of or a pointer to a gameobject. What I want to be able to do
>is something like this:
>
>GameObject go;
>
>Py_Initialize()
>...
>PyObject* po = GameObject2PyObject(go);
>...
>result = PyObject_CallObject(func, "O", po );
>...
>go = PyObject2GameObject(result);
>
>Theres alot of documentation and discussion out there that suggests
>that this should be possible but noone seems to tell you how it's
>actually done. Am I just missing something blatantly obvious?
>
>Thanks
>//ulk





More information about the Python-list mailing list