Page 1 of 5
IronPython is anything but a dead parrot.
Its new integration with Visual Studio makes it easier to use and easier to try out. Find out how to get started with the latest member of the Python team.
Python is one of the increasingly trendy dynamic languages and it is now available under the .NET umbrella but, unlike its near cousin IronRuby, it integrates with Visual Studio 2010 which makes it easier to use, easier to try out and easier to integrate with other projects. Don't worry if you don't have a full copy of Visual Studio because you can also use it with a free to download the integrated shell which gives you a Visual Studio-based IDE for free.
IronPython is an open source version of the language developed by Guido van Rossum in 1990. Python has a great many users and they are all passionate about the language and mostly about Monty Python as well. Yes, there are lots of Pythonesque (as in the well known TV series) references in the Python world, but it is a very serious language as well! It currently runs on most platforms and IronPython extends this range to .NET and Silverlight.
Python may be free and it may be a high quality language but so is C#. Why bother with a strangely named language that you probably haven’t heard very much about?
One good reason is that it is an interactive object-oriented language that has managed to take the good ideas from many other languages and meld them together into something workable.
If you have looked at early versions of IronPython now is a good time to take another look because version 2.6.1 has just been released
and this is based on the new Dynamic Language Runtime (DLR) which all of the .NET dynamic languages should be using quite soon. The DLR is an extension to the CLR designed to make it easy to implement dynamic languages. The best argument for Python, however, is to use it - so let's get started.
The main Python website is http://www.python.org/ and if you do become a fan then you will certainly need to visit it for the documentation and the code. There is also a standard Windows, i.e. not .NET, implementation of Python that you can download from the site.
If you do want the .NET version your first task is to make sure that the machine on which you plan to install it has the latest .NET Framework.
If you plan to make use of Visual Studio to work with IronPython then a good way to get started is to install the Visual Studio Shell. Even if you have a full copy of Visual Studio using the Shell means that you don't risk making a mess of its current configuration and settings. To use the Visual Studio Shell download and install it from integrated shell. This installs all of the necessary runtimes including .NET 4.0.
Following this all you have to do is do is download the IronPython Tools and run the addin. This installs not only a code editor but an interactive Python Interpreter. You can install the tools into a full working version of Visual Studio or the free Shell and get started with IronPython immediately.
If you want the full installation complete with command line environment then visit:
and download and install IronPython. The latest version is 2.6.1 and the standard msi installer is easy to use.
At this point you have a working IronPython compiler/interpreter which you can use via the IronPython console. The console is a fun interactive way of using IronPython. You can type in lines of code and have them executed immediately and in many ways this is in the spirit of a dynamic language.
The rest of this article is based on using the Visual Studio tools but the examples also work from the command prompt.
In this case the "hello world" example is trivial.
Start up IronPython Tools and and start a new console application.
This generates the files needed for a console application and the demo code:
print 'Hello World'
Which is actually slightly too little Python to create a first program. Change the code to:
print 'Hello World'
a=raw_input('Press return to continue')
If you now run the program you will see the messages displayed in the console and the program will continue when you press return.
You might like to remember to add the input command at the end of any console application examples so that you have time to see the results before the console vanishes from the screen.