Ziff-Davis Enterprise 
DevSource: Microsoft Developer Resource
Add OnsArchitectureLanguagesTechniquesUsing VSForums
 
Home arrow Languages arrow Page 2 - (More Than) Five Things You Didn't Know You Could Do With Python
(More Than) Five Things You Didn't Know You Could Do With Python
By Cameron Laird

Rate This Article:
Add This Article To:
(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.

ADVERTISEMENT

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.



 
 
>>> More Languages Articles          >>> More By Cameron Laird
 



DevSource video
Devsource Video Series
Manipulating Society through Technology
Jeremy Bailenson, Director of the Virtual Human Interaction Lab at Stanford University, talks about virtual reality, avatars, Moore's law, how real world behaviors influence online reality, and societal manipulation through technology!
>> Play video
>> Read article
>> See all videos
DevLife Blog

Julia explores the Robotics Studio! (It's for more than you think.)

MSDev Blog

Messages for Bill Gates!

Make it Work
.NET makes runtime type checking a breeze. See what Peter has to say about it in this week's tips!
News
Microsoft Counts on App Support for Vista
Microsoft has taken pains to demonstrate that Windows Vista will have ample application support.
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.