Embedding a CPython Script engine in a .NET application.

Carl Waldbieser waldbie at yahoo.com
Wed Nov 23 18:12:02 EST 2005


Has anyone had any experience embedding a CPython engine in a .NET
application?  In the COM/ActiveX world, it was pretty easy to use Mark
Hammond's win32 modules to create a script engine component that you could
expose other COM objects to, but I was not sure how I would go about doing
something similar in a .NET environment.  For example, something like:

... .NET Application code ...
'Create Foo object.
set Foo = New Foo("baz")
'Create embedded cpython script engine.
set engine = New CPythonEngine()
'Expose Foo object to engine.
engine.AddNamedItem(Foo, "Foo")
'Load python script.
engine.LoadScript("D:\scripts\frotz.py")
'Run script (uses Foo).
engine.Run()
'Get results'
set resultsCollection = engine.getResults()

Is something like this possible, or am I thinking about things the wrong
way?

I am mainly interested in knowing if this is possible with cpython, as I
understand IronPython is currently in beta.

Thanks.




More information about the Python-list mailing list