Saturday, July 17, 2010

IronPython 2.7 Alpha 1 release (and license change)

The IronPython team have just announced the first release of IronPython 2.7, an alpha 1 release. This targets compatibility with Python 2.7, and comes with interesting news about the license that IronPython is released under. There is also more of Python's standard library included; specifically two more C extension libraries previously unavailable with IronPython.

The next release of IronPython will probably be a bugfix release of IronPython 2.6: 2.6.2. Once 2.7 is complete the IronPython team will move onto IronPython 3, targeting compatibility with 3.2 - which is likely to be the current version of Python 3 when IronPython 3 is completed.

We’re pleased to announce the Alpha release of IronPython 2.7 which can be downloaded at  This is a major new version of IronPython with a number of significant updates.  Because this is an Alpha release it is not yet feature complete nor fully compatible with CPython 2.7.  Changes thus far include:
  • Updates the language to be compatible with CPython 2.7
  • Adds integrated Visual Studio support (IronPython Tools for Visual Studio)
  • Extends CPython 2.7’s documentation with useful information pertaining to IronPython
  • Adds the mmap and signal modules
  • Includes a number of performance updates and bug fixes
  • Switches the license to Apache License, Version 2.0
  • Requires .NET 4.0 and Silverlight 4.0
Python 2.7 includes a number of features backported from the Python 3.0 series.  This release implements the new builtin _io module, includes dictionary and set comprehensions, set literals, supports multiple context managers in the with statement, and adds several new functions to the itertools methods, and auto indexing for the new string formatting.  There are also numerous updates to the standard library such as ordered dictionaries and the new argparse module.
This release also includes a “IronPython Tools for Visual Studio” option within the IronPython installer.  This enables one install to get both IronPython and IronPython Visual Studio support assuming you have an existing installation of Visual Studio 2010.  This version of IronPython Tools includes a number of bug fixes as well as the start of improved WPF designer support.  We discovered very late that the WPF designer support may crash VS when not running under the debugger.  If you’d like to try the WPF designer support and give us feedback, just launch another Visual Studio instance and attach to the instance in which you are using the WPF designer support.
We’ve also updated the IronPython installer to include documentation based upon the CPython documentation.  This new .chm file includes documentation on the Python language and standard library.  It’s been extended from the normal Python documentation to include IronPython specific topics such as the DLR hosting APIs and extending IronPython from statically typed .NET languages. 
We flushed out more support for missing built-in modules which CPython includes.  This release includes the mmap and signal modules bringing better support for interoperating with unmanaged code.
As usual there are a number of bug fixes and performance improvements.  This release includes major performance improvements in cPickle, the sum built-in function, and includes support for fast exceptions which do not use the .NET exception mechanism.  There have also been improvements to significantly reduce memory usage of the IronPython ASTs.  One of the end results of these numerous improvements is that IronPython’s startup time has decreased by 10% when compared to IronPython 2.6.1.
Finally, with this release we have changed the license from the Microsoft Public License to the Apache License, Version 2.0.  We’ve made this change based upon continual feedback and questions from the community.  The Apache License will be more familiar while remaining an open source license.
- The IronPython Team

Saturday, July 10, 2010

NumPy and SciPy for IronPython and .NET

The genius of IronPython is that it provides great integration with .NET libraries. The cost of this is that you no longer have access to Python extensions implemented in C unless the IronPython team, or a third party, has created an equivalent version in C# or wrapping an existing .NET library.

One very powerful and widely used set of Python extensions come in the form of NumPy and SciPy. This is a particular problem for those interested in IronPython as there is nothing of equivalent functionality and quality in the .NET world.

There is an existing way of accessing Python C extensions from IronPython in the form of Ironclad. Ironclad was specifically designed to work with NumPy, and it works astonishingly well, but it can never be as good as a native library.

Microsoft are obviously very interested in NumPy as they have just announced an interesting partnership with Enthought, a company who are active in the Scientific Python community. The partnership is specifically to bring a .NET implementation of NumPy to IronPython. The announcement was made at the SciPy 2010 conference.

Enthought, Inc., a leading Python and Scientific Computing technology provider announces plans to extend the SciPy and NumPy libraries to IronPython and the .Net Framework. Availability of these libraries on .Net provides advanced technical computing tools to the flexible, fully-featured Microsoft Windows software environment.
"These libraries are fundamental building blocks for technical computing applications, and we are very excited to see them become available to IronPython and the .Net community," said Shahrokh Mortazavi, Architect in Microsoft's High Performance Computing Group.
"It is exciting to witness the impact SciPy and NumPy have had on the technical computing community over the last decade. We are excited to unleash the power of these tools to a whole new group of users on the .Net platform," said Travis Oliphant, president of Enthought, addressing the attendees of the SciPy 2010 conference in Austin, TX. 
SciPy and NumPy are a suite of high-performance statistical and numerical tools for the Python programming language. They are used primarily for rapid data processing and analysis in scientific and quantitative applications.  Enthought principals, Eric Jones and Travis Oliphant, were the initial authors of SciPy, and Travis was the primary author of NumPy.   Both tools are actively maintained and enhanced by a large open-source community, and have been widely adopted by leading researchers, institutions, and commercial enterprises worldwide.  
The .Net Framework consists of a Common Language Runtime (CLR) abstraction layer over the operating system, pre-built class libraries for low-level programming tasks, and a range of specialized development frameworks and technologies that enable reusable custom applications. The collaborative effort announced today will enable existing Python applications utilizing NumPy and SciPy to run un-modified on IronPython and to take advantage of the high-performance Just-In-Time (JIT) compiler technology built into the .Net framework.  

IronPython Tools for Visual Studio CTP3

At PyCon this year Dino Veihland announced IronPython Tools for Visual Studio, an extension to Visual Studio 2010 for working with IronPython. It features Python syntax highlighting, awesome auto-complete (intellisense) and a host of other features for working with IronPython code in Visual Studio. It can be used with the free Visual Studio shell and doesn't require you to own a full copy of Visual Studio.

The third CTP (Community Technology Preview) has been made available for download.

We are happy to announce a minor update to the IronPython Tools for Visual Studio.  IronPython Tools for Visual Studio (IPyTools) is a set of extensions available for Visual Studio 2010 which supports development of IronPython applications.  This release is our 3rd Community Technical Preview (CTP) and builds upon the previous two releases.  The release is a minor update which includes bug fixes and a number of small features.  You can download the latest release at
There is also one major change in that the project system is no longer based upon the files which live on disk.  Instead we now follow the normal VS project model.  This means files must be explicitly added to the project and files which you don’t want in the project won’t automatically show up.  We made this change based upon feedback from people using the tool and think it will make it more familiar for normal Visual Studio users.  Despite this change there is still support for an “implicit” project when working without a project.
Like the previous release this release includes support for Intellisense including member completion, signature help, find all references, and goto definition.  It enables quick browsing of your code using the object browser and the editor navigation bar.  It has an interactive (REPL) window that enables the development of applications in an interactive way.  IPyTools supports lightweight development without a project as well as working with project files in the tradition of Visual Studio .  Opening a .py file causes IronPython Tools to model the code in the containing directory as an implicit project for Intellisense features.   There are project templates for console, WPF, WinForms, and Silverlight applications.  WPF applications support drag-and-drop UI development.  Debugging of Python applications works just like you debug other languages in Visual Studio.
We are still working on our final licensing terms for IronPython Tools, and as such this release is licensed under a temporary limited use license.  While we weren’t able to finalize this for this release we expect to have this finalized for the next release.
The full list of changes includes a number of bug fixes:
  • Interactive window now respects VS color settings
  • Fixed default settings for insert tabs, enter completing options, list of characters to complete to
  • Fixed auto-indent inserting extra tabs on a blank line
  • Enables usage of VS common settings for smart indentation and tabs and respects those options.
  • Escape in REPL cancels both the intellisense session and the current input
  • REPL: When a completion item is focused but not selective enter should not complete it
  • REPL: We should respect the various intellisense completion options
  • REPL: We should be using IronPython’s auto intending
  • Fix repl not respecting smart up/down on startup if the window was set to be open
  • REPL: Don’t allow history if the current command is still running – instead navigate the buffer
  • REPL: Enable syntax highlighting even if a command throws an exception
  • REPL:     Remove trailing new lines from REPL history so we go back to the last line of input
  • REPL: When pasting ensure there’s a new line
  • REPL: Auto indent should delete selected lines when pressing enter
There are also a few new features:
  • New Fill Comment Paragraph feature
  • Implemented auto-dedent so it will backspace # of tabs
  • Support for disabling intellisense via normal VS mechanism
  • Support for hiding “advanced” members in intellisense (currently defined as __abc__ members)
There is one major change:
  • Removes directory based projects in favor of normal VS style projects
- The IronPython Team

Saturday, June 19, 2010

Iron Web Analyzer and Scripting TIBCO Spotfire

IronPython is a great language for application development, but also provides a readymade scripting engine for adding to .NET applications.

A fresh example of the first, an application written in IronPython, is the open source "Iron Web Analyzer" (Windows only I believe):

Iron Web Analyzer is an open source application for web masters to analyze web sites content. Iron Web analyzer employ Iron Python to analyze server responed data. Iron Web Analyzer downloads data from server and dispatches them between Iron Python Analyzer installed on application and collect analyze results produced by Python applications.
An example of the second use case for IronPython is the recently announced support for IronPython scripting in TIBCO Spotfire:
In TIBCO Spotfire version 3.1, TIBCO introduces the concept of Script Controls. Scripts Controls provide the ability to add IronPython scripts into a Text Area inside a Spotfire Analysis file. The script has access to the full Client API (from the SDK), and its goal is to perform common automation tasks.

SharpDevelop 4 and unittest2

Two weeks ago I reported on the latest news from SharpDevelop, the integration of unittest into SharpDevelop 4 for testing with IronPython. In my report I suggested that supporting unittest2 would be even better and Matt Ward has risen to the challenge.

Matt's latest blog entry shows how to use unittest2 to run IronPython unit tests in the forthcoming SharpDevelop 4 IDE:

SharpDevelop 4 has been updated to support running IronPython unit tests that use the unittest2 library.
Make sure unittest2 is on the Python path before running the unit tests.
Out of the box SharpDevelop will actually use the unittest library's test runner. This seems to work however if you actually need to use the unittest2 test runner then you can modify the following two files in the folder: AddIns\AddIns\BackendBindings\PythonBinding\TestRunner.

Tuesday, June 15, 2010

IronPython at TechEd

TechEd 2010 has just finished, one of Microsoft's biggest developer conferences. Lisa Feigenbaum, who is program manager for the Visual Studio Languages Community, has posted a blog entry with links to all the Visual Studio Language & IDE Resources from TechEd North America 2010 (C#, VB, F#, IronPython, IronRuby).

Our own inestimable Dino Viehland, the IronPython workhorse and genius, was there and gave two presentations on IronPython:

Abstract: The Dynamic Language Runtime (DLR) brings the power of dynamic languages to Microsoft .NET. It provides the plumbing for IronPython and IronRuby, a shared language hosting API, and also enables interoperability with static languages like C# and Visual Basic. Come hear how you can leverage these technologies in your own applications, and learn why dynamic languages deserve a spot in your toolbox!
 Abstract: IronPython Tools for Visual Studio is an extension for Microsoft Visual Studio which provides Python programmers with a great development experience inside of Visual Studio. It supports all of the usual Visual Studio features such as editing including rich Intellisense, debugging, light weight Python projects, and participating in Visual Studio solutions. In addition to the usual Visual Studio features it also supports a REPL window for a lightweight development experience which Python developers are accustomed to. Come and see IronPython Tools in action and see some new and exciting ways to work in Visual Studio.

Wednesday, June 09, 2010

Finding lyrics and converting Word files to text

Two fun, and possibly useful, recipes using IronPython have surfaced in blog entries recently.

This first recipe is from Mark Bloodworth, a Microsoft architect with a fondness for Python and IronPython:
I was looking some lyrics up online this week, so I wondered how hard to would be to write a simple application to find lyrics to your favourite song.  Or to your least favourite song.  Or, in fact, to any arbritrary song.  Via programmableweb, I found the API to lyricsfly, which looked easy to use.  Another IronPython console app beckoned.
Keeping it simple, I decided to use optparse to parse the command-line options and urllib to make the http calls.  This way the program can be called with the user_id that lyricsfly requires (head to their website and you can get a temporary weekly key to try this out) along with the artist name and song title.  What I decided not to do at this stage was to process the resulting XML.  Or handle any errors.  Or handle cases where the user_id, artist or title is not supplied.  But, although rudimentary, it works. ...
While SaveAs method in Word has Encoding parameter, it wasn’t quite clear, how would I specify it from pywin32.
So, my next attempt was to use IronPython, since it has native .NET interface with Office. The biggest advantage of this approach was the fact that you can do dir() on all objects and methods in IronPython shell.
After some googling on encodings, and IronPython Word scripting, here is the script I came up with. ...

Wednesday, June 02, 2010

Unit Testing with IronPython in SharpDevelop 4

Microsoft may have finally pulled out their collective thumbs and started to support IronPython in Visual Studio, but SharpDevelop has always led the way as far back as 2007 in supporting IronPython.

SharpDevelop 4 is now under development and integrates with the unittest module to support unit testing with IronPython. This feature requires Python 2.6 to be installed, and IronPython debugging is not currently working with SharpDevelop 4, but it looks like it will a great release.

Matt Ward gives us the details in his latest entry on the SharpDevelop community blog:

SharpDevelop 4 has been updated to support unit testing with IronPython.
First you will need to install Python 2.6. SharpDevelop uses the standard Python unit test library ( to run the unit tests.
Once the project reference is added the unit tests can be run in the normal way by right clicking in the Unit Tests window and selecting Run tests. You can run all the tests in a project, all tests in a class or a single test method.
The output generated when running the unit tests is shown in the Output window.
Test failures are displayed in the Errors window. Clicking an error will open the corresponding code in the editor.

Of course support for unittest2 would be even better... 

Tuesday, May 25, 2010

A Good Mix 36: Jim Hugunin, Selenium Two, Embedding IronPython & IronPython with Expression Blend

Another collection of IronPython and DLR related articles from recent weeks.

Jim Hugunin is a bit of a Python veteran. As well as being the creator of two implementations of Python (Jython and IronPython), he also started the Numpy project (back when it was called Numeric). Not long ago he was swallowed by Microsoft, who also took on the development of IronPython and turning it into the Dynamic Language Runtime.

In this video interview Jim explains not only how he got involved in Python, but also what he has been up to recently.
One of the ways that .NET helps you separate your visual design from your application logic is through XAML; an XML based declarative language that can be used with both Windows Presentation Foundation (WPF) and Silverlight.

Naturally there are design tools that will generate XAML. Visual Studio is one of them, but the best one is Expression Blend. XAML has features that make it particularly suited for integration with statically typed languages (statically binding events to your code in your XAML for example), but it can still be used with IronPython - slurping up the XAML dynamically at runtime (including generating or transforming XAML) with the XamlReader.

Simon Segal has been looking at how he can use both Expression Blend and Visual Studio with his IronPython projects:
Finally I decided to synchronize two separate .XAML files in each of the two different projects, so the challenge was to find the most unobtrusive way of working in both IDE’s and easily syncing the the .XAML files after edits had been made. Given that one of the IDE’s was running a dynamic language with a REPL built in, I thought it shouldn’t prove too difficult.
Like I said its far from a perfect solution and to be frank it’s somewhat annoying however my frustration is another thing altogether if I’m faced with doing all my layout and design in Visual Studio – so I will live with it for the moment. Hopefully the IronPython team and or the Expression Blend Team can find a solution that flows changes through more seamlessly in the short term and the perhaps in the long term allow us to open IronPython and IronRuby projects in Blend.
By the way if your wondering about the codename of the project that drove this adventure (PONGO) – the answer is yes if you guessed that it’s something that revolves around IronPython and MongoDB and I will be blogging about that more in the coming weeks.

Selenium is probably the best known / most widely used web testing tools and it supports a host of different languages. At Resolver Systems we've used the .NET Remote Control for Selenium from IronPython for quite a while. This article is a tutorial on using Selenium 2 with IronPython and Internet Exploder:
This tutorial is to show how to use the .NET Selenium 2 with dynamic languages that run on the .NET Common Language Runtime. This tutorial uses IronPython.
To complete this tutorial you will need to have IronPython installed and you will also need to download the .NET Bindings from Google Code
This tutorial will not be using the Remote Driver and it will be using the InternetExplorerDriver as this is the only complete browser at the moment that doesn't need to be built from the Repository.
Yes, over the years I've been making entries in this blog we've seen a whole host of blog entries showing examples of embedding IronPython in .NET applications, but it is always fun when another developer discovers just how easy it is:
A requirement I have in an app I am writing is to allow the administrator to set up formulas which can be calculated at runtime. The client app is completely disconnected from Enterprise Core Objects, it uses a (query/command)->response approach so I didn’t want to expose OCL on the client, I also didn’t want to use OCL because I didn’t want arbitrary browsing of the model.
So I have been looking at IronPython – and I like it! I’m not going to go into details of what this code does, I’m just going to paste it so that you may take a look. In short the requirement is for the Admin to be able to retrieve values from the DB by name and perform whatever logic they wish in order to return a decimal result.