Hello Python Community,
We’re quite pleased to announce the release of
“IronPython 2.6 CTP for .NET 4.0 Beta 1”. This is our second
preview of IronPython running under the Dynamic Language Runtime that is built
directly into a .NET 4.0 release! As before, this release allows you to
use IronPython objects and types as .NET 4.0 dynamic objects from within
C# and Visual Basic code. While this release does share a bit in common
with the upcoming IronPython 2.6 Beta 1 release (e.g., a number of MSI
improvements), the core functionality is essentially that of IronPython 2.6
Alpha 1. Please also note that “IronPython 2.6 CTP for .NET 4.0
Beta 1” will run only under .NET 4.0 Beta 1.
Here’s a small example showing just how powerful the
new dynamic feature is for taking advantage of dynamic language
functionality in statically typed languages:
<mock.py>
import random,
math
class
Mock(object):
def __getattr__(self, key):
"""Mock objects of this type will dynamically implement any
requested member"""
return
random.choice(["hello world", math.pi])
</mock.py>
<dynamic_demo.cs>
using System;
using
IronPython.Hosting;
using
Microsoft.Scripting.Hosting;
public class
dynamic_demo {
static void Main()
{
var ipy =
Python.CreateRuntime();
dynamic mock =
ipy.UseFile("mock.py");
dynamic m = mock.Mock();
//The Python Mock type dynamically implements any member that is
requested of it
System.Console.WriteLine(m.the_csharp_compiler_cannot_possbily_know_this_member_exists_at_compile_time);
}
}
<dynamic_demo.cs>
To try out this preview release:
1.
Install some variant of .NET 4.0 Beta 1 or Visual
Studio 2010 Beta 1. E.g., http://www.microsoft.com/downloads/details.aspx?FamilyID=ee2118cc-51cd-46ad-ab17-af6fff7538c9&displaylang=en
2.
Install IronPython.msi from http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27320
3.
Follow any of the many dynamic walkthroughs
online. http://blogs.msdn.com/vbteam/archive/2008/12/17/walkthrough-dynamic-programming-in-visual-basic-10-0-and-c-4-0-lisa-feigenbaum.aspx
would be a good start
Have fun!
The IronPython Team