Python Programming, news on the Voidspace Python Projects and all things techie.
Embedding IronPython 2 Examples
I'm giving a talk at the ACCU Conference 2008 next week, on IronPython & Dynamic Languages on .NET. I've finished my talk slides (well - 3rd or 4th draft at least) and just need to practise now. The talk is one and a half hours long (poor audience), which means we have time to get into Silverlight and embedding IronPython (or other DLR languages) in .NET applications:
The talk includes two examples of embedding IronPython. I've turned those examples into an article:
Up until now the DLR hosting API has undergone major changes with almost every release. With the latest IronPython 2 release, the DLR is now in beta and is approaching the kind of stability outlined in the (79 pages of complexity) now fairly out of date DLR Hosting Spec.
Hopefully it is at least stable enough that my examples won't require major surgery for the next release.
The first example is trivially easy. I've finally written a calculator. I call it 'My First Calculator' and it uses IronPython to evaluate numerical expressions you enter through the user interface.
The second example is only slightly less trivial, but perhaps more useful. The IronPython evaluator:
It demonstrates exposing a scripting or plugin API, by publishing objects with events that user code can subscribe to, or fetching objects out of the scope after executing user code.
Both examples are in C# and downloadable as Visual Studio 2008 projects(with binaries). Because IronPython 2 Beta 1 doesn't yet work with Mono, they are Windows only for the moment...
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.