I am a Python programmer and a Python enthusiast. I love the expressive syntax of the language. I have used it for automating my tasks and developing web sites. I have developed PyQT desktop apps as well. Today I am going to focus on IronPython, another cool distribution of Python programming language. It’s based on the .NET platform introduced by Microsoft. It aims at providing a dynamic runtime language for the .NET platform.
I am using genuine Windows 7 on my Notebook PC. I’ve been trying to install Microsoft Visual Studio 2008 for the last couple of days. But I failed every time. I guess it’s happening because I am using Windows 7 64bit edition. After repeated failure with VS2008, I decided to try .NET platform with Python. So, I went to IronPython home page (see link at the bottom) and browsed the downloads section. By default, it prompted me to get IronPython 2.6 for .NET framework 4.0. I didn’t have v4.0 of .NET installed, so I downloaded the one for .NET 2.0 instead. Tell you what, .NET 4.0 is more than 40 MB download and I am running a bit tight on available data transfer 😛
The setup was pretty easy. I ran the MSI file and it installed for me. But in case, you don’t have .NET 2.0 installed, you’ll need to get that. (See link at the bottom).
After installing IronPython, I noticed a cool looking IPY (IronPython :P) console. It works just like the interactive python shell. Remember, the version I installed didn’t put IPY in the system path. So, typing “ipy
Here’s a sample “Hello World!” GUI I wrote to test IPY:
1 2 3 4 5 6 7 8 9 10 11 12 |
import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import Application, Form class HelloWorldForm(Form): def __init__(self): self.Text = 'Hello World' form = HelloWorldForm() Application.Run(form) |
You have to import the “clr” module first. Add a reference to the .NET namespace you want to use. Then use that namespace just like a Python module.
Cool. Isn’t it? So, why should you use IronPython? Good question. Most windows users will by now have .NET framework 2.0 or later installed. The IPY installer is only 6 MB. The end user of your application will need to download less and install less. Please remember PyQT and wxPython are pretty heavy. JAVA requires a huge installation as well. IronPython cares both about you and your users. You get a fantastic expressive language and an excellent platform. Your users get the ease and comfort of installation. Also remember, with Mono, IPY is now cross platform. So your programs will run on other operating systems as well.
With IronPython you can do so many things — develop ASP.NET web sites, work with Robotics and Silverlight, develop games with XNA and build robust programs. So if you’re a Python programmer, come on and mix up .NET and your python wizardry to create something awsome 😉
Resources / Links:
IronPython Home Page
IronPython Download
.NET framework 2.0 Redistributable Package
IronPython Cookbook