Showing posts from July, 2008

IronPython in Action: All 15 Chapters Available in Early Access Program

All fifteen chapters (427 pages) of IronPython in Action are now available in the Manning Early Access Program . The last few chapters (12 -15) are now being perused by our reviewers, so there may be minor changes, but this is an important milestone. You can read more about the last chapter (Embedding IronPython in .NET Applications) on my blog, and see the whole table of contents on the IronPython in Action website: Last Chapter of IronPython in Action Finished IronPython in Action Table of Contents The new chapters available in the "MEAP" include Christian Muirhead's chapter (12) on Databases and Webservices, plus chapters on extending & embedding IronPython and Silverlight. Still to do are the index and appendices plus updates to the earlier chapters (particularly the first chapter) in the light of changes to IronPython over the eighteen months or so that we have been writing it.

IronPython and Active Directory

Two new recipes have been posted to the IronPython Cookbook . They are both about interacting with Active Directory from IronPython. ActiveDirectory and RefreshCache DirectoryServices to Dictionary The first article shows how to use ' System.DirectoryServices ' and ' RefreshCache ' to load attributes not exposed by ADSI. The second is a helper object that turns ' DirectoryService' objects into Python dictionaries, which are easier to work with.

Inside IronPython AST - Parts 1 & 2 (Chinese)

These articles on the Chinese "Aim and Action" blog look really interesting, if only I could understand them. It is a two part look at IronPython 2 from the inside - exploring how IronPython (and the DLR) parses Python code and the resulting AST. Although there are some diagrams I'm afraid you won't get much out of them if you can't read Chinese. Still, they look good. Inside IronPython AST 1/2 Inside IronPython AST 2/2 In fact this chap has done a series of articles on IronPython , although the other entries more cover Python features like decorators, higher order functions and generators. It's nice to see that the Python and IronPython community is truly international.

.NET 4, C# 4 and the DLR

The recent C# 4 Meet the Design Team Video discussed the future of C# 4, and in particular how it might have more features inspired by dynamic languages and offer better interoperation with the DLR languages like IronPython and IronRuby. (Currently dynamic objects created using these languages can be used from statically typed .NET languages - the DLR provides an API to do this - but it could certainly be made more convenient ). In this blog entry, Jb looks at potential DLR integration into C# 4 and particularly examines the similarities between LINQ Expression Trees and DLR ASTs (in fact these will be merged completely at some point to use the same representation for LINQ expressions and parsed dynamic languages - this will not only be simpler for developers working with both but make it a lot easier to bring LINQ into DLR languages): .NET 4, C# 4 and the DLR UPDATE: He's followed up with a new post, confirming that in IronPython 2 Beta 4 (not yet released but the sourcecode is

4 different ways to execute IronPython code using the DLR Hosting API

The DLR hosting blog has posted another article on using the IronPython embedding API. This entry explores different ways you can execute Python code (four of them). It introduces the ScriptScope , ScriptSource and CompiledCode classes: 4 different ways to execute IronPython code using the DLR Hosting API

IronPython Projects, IronPython IDEs and Python in the Browser with Silverlight

IronPython in Action is nearly complete, and once it really is finished I will have more time to work on projects that have been waiting in the wings. This includes several IronPython related projects (including a documentation tool that runs under IronPython, user controls specified in XAML for dynamic languages for WPF and Silverlight, and an IronPython IDE): Too Many Projects, Too Little Time The IronPython IDE of course is IronEditor , a project by Ben Hall to create an IDE for Dynamic Language Runtime languages and to run on Mono and .NET. The Industrialization of Software blog has a great roundup of (.NET) dynamic language IDEs and interactive environments. He is particularly focussed on web based environments: Web Based IDE's and Dynamic Languages on .NET His blog entry mentions Silvershell , a Python interpreter that runs inside Silverlight 2. It is written by Dan Eloff and has nice features like auto-indentation and completion. Currently it only works on IE, but Dan wil

PyCon UK: IronPython Tutorial and Talk Lists Up

September 12-14th at the Birmingham Conservatoire is the 2nd UK Python Conference, organised by the UK Python community. This year the conference starts with a tutorial day, and Christian Muirhead, Menno Smits and I will be running a half day IronPython tutorial. The tutorial day is only £30, so if you're interested in learning about IronPython it is an ideal opportunity. Tutorials Schedule Currently Accepted Talks Booking (early bird rate still available for a few days) Other topics include Python & WMI, testing, lots of Django, PyPy, Google AppEngine, Pyglet and Python on OpenMoko. On my blog is a summary of the accepted talks and tutorials .

Twining, TwyDL (IronPython DSL)

David Seruyange has been working on his IronPython database DSL Twining . Twining, TwyDL He's been using Twining to export tables to SQL and also working on the ability to generate schema objects: database(cn).create.table("Employees", [ col.ident("EmployeeID"), col.string("FirstName"), col.string("LastName"), col.numeric("Salary") ] )

IronPython and Silverlight - Part 2

There is a new post on "Kim's Blog" about Silverlight. This is a follow-up to IronPython and Silverlight Part 1 . IronPython and Silverlight - Part 2 The blog entry is in French, but with clear example code using WebClient to make network requests and fetch a page (or data) from a specified Url. WebClient is asynchronous, so to fetch resources with it you must call DownloadStringAsync and provide a handler for the DownloadStringCompleted event. (Although I'm pretty sure that you don't need to wrap the handler method with an explicit DownloadStringCompletedEventHandler delegate as IronPython will do this for you.)

CLS Compilation of IronPython

In IronPython (and other Dynamic Language Runtime languages) Python classes are not static .NET types. There are various reasons for this. .NET classes can't be garbage collected (assemblies can't be unloaded - unless you load them in another AppDomain and unload the whole AppDomain). Additionally dynamic languages typically allow you to add and remove members at runtime and in Python you can even change the base classes at runtime. For instances of Python classes we can also change the class at runtime, not usually recommended but possible... This means that normally a Python class can't be a static .NET type, instead Python classes are .NET objects (instances of their metaclass - for new style classes without a custom metaclass that means ' PythonType '). This isn't without problems - in order to apply .NET attributes you basically need a sttic type. This leaves a hole in the interoperation between Common Language Runtime features and dynamic languages, an

How to create IronPython objects of types defined in C#

A new article from the " DLR Hosting blog " on creating Python types that inherit from .NET types when hosting IronPython. Inheriting from .NET types is straightforward in IronPython. The builtin Python types are all .NET types implemented in C# and you can inherit from these, just as in CPython. The interesting part of the blog entry is that it shows you to how to setup the hosting environment - to make your custom .NET types available to Python code running in the hosted Python engine. How to create IronPython objects of types defined in C#

Python (and IronPython) for Executives

ophirk has published a great essay on getting Python / IronPython accepted as a development language within the company he works for: Python for Executives IronPython has worked well for them because of easy integration with C# and the .NET infrastructure. He lists the four main fears that their managers had to face in adopting Python: Recruiting - It turns out that smart and innovative people are attracted by Python .Innovative smart people can also learn Python very quickly. Risk - in one year we had only five cases where a Python specific bug occurred. We had many more ASP. NET, JavaScript, HTML and even Java specific problems. Maturity - not only is Python very solid, so is IronPython. The code is stable, the smart features work, the community is responsive and the libraries are rich. The only downside is the IDE and Visual studio integration, but this is progressing as well. Performance - Python flexibility allowed extremely fast optimizations at the system and algorithmic l

IronEditor: An Editor for Dynamic Languages on .NET

Ben Hall, a .NET developer from the UK, has announced a new project to create an IDE specifically targeting IronPython and IronRuby. In the future the project will also be extended to cover all languages that use the Dynamic Language Runtime. Announcing IronEditor - An Editor for IronRuby, IronPython and other DLR languages IronEditor Homepage and Download on Codeplex Ben's goal is to create an IDE for Dynamic Languages that is lighter-weight than Visual Studio. Out of the box the project already supports IronPython and IronRuby, including the creation of new projects or source files and executing code. IronEditor is based on Windows Forms and has a syntax highlighting code editor. Currently to build IronEditor you will need Visual Studio 2008 (Express is fine), but there is a binary available for download. The blog entry shows screenshots of IronEditor running on Mono. Mono compatibility is an important goal for IronEditor. Currently the only feature missing on Mono is syntax hi

Review of IronPython in Action

It isn't even published yet, but there is already a review of IronPython in Action ! Noel, who works in 'cheminformatics' and is an avid Python user, has been reading the Early Access version (currently the first eleven chapters) and has posted his thoughts: Review of IronPython in Action The obligatory introduction to Python is quickly and efficiently dealt with before moving on to the main subject - accessing .NET classes and creating a GUI application. For those coming from C# to IronPython, there is a whole chapter on unit testing with Python, as well as another that covers everything from Python magic methods to metaprogramming. In short, for any serious users of IronPython, this book is a must have. It may also convince those using C# to make the switch to a better and more productive life with Python..

Turning Internet Feeds into TV Feeds with WPF and IronPython

Jon Udell has been writing a series of blog entries on a project to display RSS feeds in a publicly accessible way. He settled on WPF (Windows Presentation Foundation - part of .NET 3) as the user interface, but couldn't wire up the timer callback to refresh the display periodically from IronPython. After prototyping in C#, and with a bit of help, he got an IronPython version working: How to wire up a timer-triggered WPF event handler in IronPython Jon's project is to make information more accessible by displaying it on his local public access cable TV. Although the IronPython and C# versions of this client are virtually identical, he is leaning towards the IronPython one as it would be easier for the folks at the TV station to customize / modify it.

Embedded IronPython 1 - The Simple (and Chinese) Way

This blog entry by Terence Chao is very short, and barring about two words all in Chinese. However it links to a PDF document (by the author of the blog) with examples of embedding IronPython 1 in C# and using IronPython to automate Excel. More Chinese text, but straighforward code examples: Embedded IronPython 1 - The Simple Way His Excel automation example takes command line arguments to convert Excel files into CSV files. If you are (or can read) Chinese, then you might also be interested in these entries: Dynamic Language Console: Create Python Host A simple example of the IronPython 2 hosting API, executing code from a string. This entry is mostly code, with screenshots and diagram. IronPython Tutorial This one is mainly text, but appears to be a pretty impressive IronPython tutorial. It looks like it is the start of a translation of the tutorial (by Microsoft) that comes with IronPython. You can find it on the web here . IronPython and Silverlight Another blog entry with screen

Easier Python Evaluation from C#

Ronnie Maor uses IronPython with C# at work. He has written an extension method, to the IronPython 1.1 PythonEngine, to make evaluating Python expressions simpler. Easier Python Evaluation from C#

DLR Hosting Sample : QikScript - Handle Visual Studio 2008 extensibility events in IronPython

Sesh Pillailokam has written another blog entry on using the Dynamic Language Runtime Hosting API. This blog entry shows how to extend Visual Studio 2008, using IronPython to handle Visual Studio events: DLR Hosting Sample : QikScript - Handle Visual Studio 2008 extensibility events in IronPython The entry includes a downloadable example called 'QikScript', which is a Visual Studio AddIn written in Python. It handles the 'WindowCreated' and 'DocumentSaved' events.

C# 4.0: Meet the Design Team

A channel 9 video interview with Anders Hejilsberg and the C# design team on the future of C#, specifically C# 4.0. The team (and video) includes Jim Hugunin (creator of Jython and IronPython) and the discussion rambles around language design issues, the importance of concurrency, and how dynamic languages are influencing C# and the Common Language Runtime. The video is an hour long (and the high quality version around 950mb to download), but very entertaining - although Anders doesn't seem to realise that there are plenty of IDEs for dynamic languages with capable intellisense features. C# 4.0: Meet the Design Team From the introduction to the video: C# 4.0 will contain many new features that will help developers be, yeah, you've heard it before, more productive. There's also some very interesting work going on with adding dynamic constructs to the language, which is of course very interesting given the static nature of the C# language. In this video you will not get an

The Differences Between IronPython and CPython

IronPython is an implementation of the Python programming language written in C#, running on the Microsoft .NET framework and Mono. This naturally means that there are some differences between IronPython and CPython. The most significant differences being: IronPython uses the underlying .NET basic types. Strings are therefore Unicode by default, as they will be in Python 3. IronPython compiles Python code to .NET assemblies, and uses neither Python stack frames nor bytecode. CPython extensions written in C, using the CPython C API, don't work with IronPython (at least not until Ironclad is completed). There are several lesser differences as well. For example, did you know that CPython catches string exceptions by reference whereas IronPython catches them by value? The IronPython team have written up the differences between the two implementations and have now put them up on wiki pages: Differences between IronPython 1.0.x and Python 2.4.3 Differences between IronPython 1.1.x and

IronPython the Road Ahead: a Post 2.0 Roadmap

In recent days both Todd Ogasawara and Steve Holden have wondered what the future holds for IronPython, particularly with regard to how and whether it will support Python 3.0 which edges ever closer. Harry Pierson has been goaded into mapping out the road ahead for IronPython, at least partly due to utterly unfair comments from me over Twitter . IronPython Post 2.0 Roadmap In this blog Harry Pierson's sets out the IronPython teams plans, which include: Pushing out a new 1.1.2 release in the coming weeks, the last planned released of the 1.X (pre-Dynamic Language Runtime) branch of IronPython Getting IronPython 2 (currently still in beta) completed by the end of the year. IronPython 2 targets compatibility with CPython 2.5. Python 2.6 support (both language and library compatibility) will come sometime in the IronPython 2.1 lifecycle. Along with this will be Visual Studio integration. An IronPython 3 that will target Python 3. Harry also talks about the hoops he is jumping throug

Visual Studio IronPython Integration Deep Dive

The Visual Studio SDK demonstrates how to customize Visual Studio, providing IronPython integration as an example of how to use many of the advanced features. nows has a 'deep dive' document that explores the SDK through the IronPython integration. Visual Studio IronPython Integration Deep Dive The IronPython Visual Studio SDK example provides, among other things, a full implementation of the Python programming language. The IronPython integration into Visual Studio, included as part of the SDK, provides not only a full IDE experience for Python developers interested in exploring this Python implementation, but also a useful framework from which to dissect a non-trivial Visual Studio language service and development environment. While the VS SDK provides some documentation on the subject, along with the source code of the IronPython Visual Studio Integration itself, it can be overwhelming to attack such a large source base without some kind of guide to

GUI Automated Testing: Simulating User Input

The next post on the "GUI Automated Testing" blog continues the theme of testing .NET applications with IronPython. This entry supplies a useful library of routines to simulate user input using (key strokes, mouse events etc) the Win32 API. Lukas Cenovsky illustrates using this library to interact with an application under test. Simulate User's Input

Debugging in IronPython Studio with PythonEngine

Another post on Michael's Random Technology Posts blog. This one on how to use the .NET debugger with IronPython code and the IronPython Studio IDE (which can run standalone or integrated with Visual Studio). The setup Michael uses some C# (embedding the PythonEngine), but shows nice screenshots for the whole process: Debugging in IronPython Studio with PythonEngine

ASP.NET and Dynamic Languages

ASP.NET has been overshadowed recently, both by Silverlight and the ongoing development of the ASP.NET MVC framework which is heavily influenced by Rails and Django. The IronPython support in ASP.NET was released in July last year, but not much has apparently happened since then. Jimmy Schementi blogs about hope for the future of dynamic languages in ASP.NET: ASP.NET and Dynamic Languages

How to Redirect Output from Python Using the DLR Hosting API

seshadripv has a long blog entry showing how to using the core classes in the Dynamic Language Runtime hosting API to divert the standard output and error streams (using the ScriptIO class) on a hosted Python Engine. How to Redirect Output from Python Using the DLR Hosting API

Snippets from Devhawk

Harry Pierson (Devhawk and Microsoft IronPython PM) regularly blogs interesting snippets of news. His "Morning Coffee 166" edition has several IronPython and Dynamic Languages related pieces of news. There is a new Dynamic Language Runtime Hosting spec available ( doc , pdf ). If you're embedding IronPython into languages  like C#, VB.NET or even F# or Powershell, this is an invaluable and surprisingly readable document (well - if you like reading heavily technical documents). As IronPython PM Harry has a new boss - Dave Remy. Dave doesn't blog, but Jim Deville, a new member of the Dynamic Languages team working mainly on IronRuby does . There is also yet another  new member of the Dynamic Languages team. Oleg Tkachenko, who also blogs . IronRuby has a new wiki and homepage . The front page has a bright and shiny picture of Matz (Ruby BDFL) wearing a Python T-Shirt! Devhawk: Morning Coffee 166

IronPython Parser AST Walker

A post by Michael (not me - another one...) on how to use the IronPython 1.1. parser from C#. By creating new expression walkers that inherit from the AstWalker class you can do interesting things with Python code parsed into an IronPython Abstract Syntax Tree: IronPython Parser AST Walker

IronPython 1.1.2 RC1 Released

IronPython 1.1.2 RC1 has just been released. This is the first release on the stable branch of IronPython for quite some time, and if all is well a 1.1.2 final should follow soon. Download IronPython 1.1.2 RC1 IronPython 1.1.2 RC1 Release Notes As might be expected, this is mainly a bugfix release. However, there is at least one major new feature with the addition of the _winreg builtin module. This release also fixes the following codeplex work items: 16368 1.1.2: nt.access is missing 16402 1.1.2: implement _winreg module 15105 1.1.2: endpos is zero in IronPython 1.1.1 16335 1.1.2: Event handlers can cause circular references and leak memory 16337 1.1.2: Trivial: Implement float. _lt_ (float) 16338 1.1.2: Using lambda in class definition will add into the 16342 1.1.2: calling base class _call_ invokes constructor instead 16343 1.1.2: problem with _slots_ and _init_ in new-style classes 16347 1.1.2: Trivial: popen shouldn't open new window 16348 1.1.2: Removes the inexist

Python Generation using the Code Dom

IronPython 1 has a CodeDom provider. This means that IronPython Studio can use it to generate Python code from the Windows Forms and WPF designers, and even generate executable files from Python projects. This is one feature that hasn't yet made it into IronPython 2, but there are strange rumblings from the IronPython team that it may just make it. In the meantime, 'tech-michael' has a blog entry showing how to use IronPython CodeDom to generate Python code from metadata. Python Generation using the Code Dom

How to Invoke Python Functions from C#

seshadripv has posted a blog entry, the second in a series, on using the DLR hosting API from C#. This entry shows how to execute Python code in a ScriptEngine to create a Python function, and then invoke that function (returning results) from C#. The entry includes a description of all the major components used, and full sample code. How to invoke a IronPython function from C# using the DLR Hosting API

Programming Languages @ PDC 08

Harry Pierson (IronPython PM for Microsoft) has posted some of the programming language sessions that will be part of the PDC 08 conference. Naturally this includes a session on dynamic languages. Deep Dive: Dynamic Languages in .NET The CLR has great support for dynamic languages like IronPython. Learn how the new Dynamic Language Runtime (DLR) adds a shared dynamic type system, a standard hosting model, and support for generating fast dynamic code. Hear how these features enable languages that use the DLR to share code with other dynamic and static languages like VB.NET and C#. Programming Languages @ PDC 08 For programming language geeks it looks like there is a lot to looks forward to at PDC, with sessions on F#, the future directions of both C# and VB.NET (both of which will include support for better working with dynamic languages), and C++.