(More Than) Five Things You Didn't Know You Could Do With Python - ' Python Does ' (
Page 2 of 5 )
.NET (Almost)">
Python Does .NET (Almost)
In principle, the same is true with .NET as with COM. Microsoft worked closely with Python insiders when it was first designing .NET, and "Project 7" planned Python as a fully-capable .NET language since 1998.
Those .NET capabilities aren't as convenient as the corresponding COM ones, but it's widely expected they'll become more so later this week. As things stand now, to write a .NET client requires use of a Python "extension" called PythonNet.
While PythonNet is a freely-available add-on, it's generally not part of a standard installation. Once you've downloaded and installed it, though, you can work with any .Net Classes. Here's an example with Drawing:
from CLR.System.Drawing import Point
p = Point(10, 5)
In this fragment, p is now a first-class binding in Python; it can be referred, passed, interrogated, and so on, just like any other Python value. At the same time, it's a .NET Point. In fact, Python even lets you subclass .NET definitions, as well as invoke methods, manage events, call indexers, instantiate delegates (including multicasts),
dereference arrays, and iterate collections. Python gives almost complete access to .NET facilities; the most prominent exceptions are that Python doesn't respect CLR security, and
Python semantics don't provide for value types. The practical consequence of the latter is that some operations that C# can write as assignments, Python must do in two steps, as copies.
There's no effective way to write .NET services with Python now. However, this is the week of PyCon2005, the biggest of several annual conferences focussed on Python. The first keynoter on the first morning of PyCon2005 is
scheduled to be Jim Hugunin, a researcher for Microsoft Corporation. Gossip has it that he'll announce an enhanced release of IronPython, a project designed exactly to make Python a full-fledged .NET language.