Posts

Showing posts from March, 2009

IronPython 2.6alpha 1 Released

Dave Fugate has just announced the release of IronPython 2.6 alpha 1. IronPython 2.6 Alpha 1 Download Page There is also a page comparing performance of the IronPython release with Python 2.6.1. The performance shows a degradation because the new adaptive compilation techniques are very much a work in progress: IronPython 2.6a1 Performance The announcement: We’re pleased to announce the release of IronPython 2.6 Alpha 1. As you might imagine, this release is all about supporting new CPython 2.6 features such as the ‘bytes’ and ‘bytearray’ types (PEP 3112), decorators for classes (PEP 3129), advanced string formatting (PEP 3101), etc. The minimum .NET version required for this release is the same as IronPython 2.0; namely .NET 2.0 Service Pack 1. Unlike the 2.0 series of IronPython, we plan to release only a couple Alphas and Betas of IronPython 2.6. As such, it’s key that we get your feedback on the release(s) quickly to incorporate requested changes. Besides CPython 2.6 features,

The Coding Geekette's Book Reviews: IronPython in Action

Sarah Dutkiewicz is the Coding Geekette , a .NET developer who also like Python and has presented at many .NET community events on IronPython. Sarah is speaking at PyCon 2009 on FePy , the community distribution of IronPython: Pumping Iron into Python: Intro to FePy . In a recent blog entry she reviews IronPython in Action : The Coding Geekette's Book Reviews: IronPython in Action Overall, I would recommend IronPython in Action for anyone wanting to learn IronPython. The examples in this book were easy to follow and very applicable to everyday programming. Even if you're an experienced IronPython programmer, IronPython in Action would be great to have on hand as a reference. I'm looking forward to buying the final copy once it comes out, just to have as a reference (and to plug in my future IronPython talks).

Exploring ActionScript Bytecode with IronPython

OK, so I'm not fully certain what this about - but it certainly looks interesting. AbcExplorationLib is " a library to read and write ActionScript Byte Code (ABC) files. When completed it could be used for compiled program analysis or as part the back end of an experimental compiler. It is written in F# but it could be used from other .NET languages. Inspiration for this library comes from many excellent libraries for bytecode manipulation such as BCEL, ASM, Cecil or System.Reflection.Emit ". The blog entry linked to here, is about experimenting with ActionScript bytecode from IronPython; and in particular with the bytecode for the switch statement. Support for the LookupSwitch opcode in AbcExplorationLib Given the following ActionScript code: var x; for(x = 1;x <> switch(x) { case 1: print("one"); break; case 2: print("two"); break; case 3: print("three"); break;

Numerical Computing in IronPython (with and without Ironclad)

John Cook posted a couple of entries on getting started with IronPython, which I linked to in the last IronPython-URLs selection post . Since he made those entries he's been posting a bit more on IronPython, and specifically numerical computing with Python and IronPython. IronPython Article on Codeplex Computing Normal Probabilities in IronPython John has written an article on CodeProject showing standalone code for computing normal probabilities in IronPython. The algorithm is based on formula 7.1.26 from Handbook of Mathematical Functions by Abramowitz and Stegun, affectionately known as "A&S." The algorithm given in A&S is for computing the error function erf(x) . The error function is related to the the function Phi by a simple transformation. (The corresponding function in SciPy is scipy.special.erf .) Because this code has no dependencies other than the standard math module, it should run anywhere Python runs. It has been tested on Python 2.5, Python 3.0, an

Extending a .NET Application with the DLR: 3 Articles

Three different blog entries on extending an application by embedding IronPython and the Dynamic Language Runtime. A 3 minute guide to embedding IronPython in a C# application Creating a simple calculator program and an evaluator app that lets you enter code into a textbox and press a button to execute. Both embed IronPython and are available for download. These simple examples demonstrate how easy it is to add an embedded scripting language in a C# application. Using IronPython to extend your .NET applications Another simple example, but this one more directly aimed at those wanting to add scripting support into their applications: There’s another interesting application for IronPython and IronRuby: adding scripting support for your existing .NET applications. This can be a very useful and powerful way to extend your applications and give the user freedom to program their own mini programs, scripts or whatever in your applications. It could be good for defining rules, assigning and ca

Binding dynamic types in WPF using IronPython and DLR

There have been a couple of projects in the past integrating IronPython into WPF XAML to add more dynamic features: IronPython and data binding plus the PyBinding markup extension Embedding DLR Scripts in XAML WPF, Windows Presentation Foundation, is the new User Interface library by Microsoft which is part of .NET 3.0. It uses the graphics card GPU to do UI drawing, so as well as being more powerful than Windows Forms it can also perform better. It isn't available in Mono though, so has the disadvantage of not being cross-platform. XAML is the XML markup used to describe GUIs, transformations, etc in WPF and Silverlight (which uses a subset of WPF XAML). Here's (yet) another way of adding dynamic features to WPF. This time it is for dynamic binding: Binding dynamic types in WPF using IronPython and DLR Covered in this post: Creating classes in IronPython and comparing with C# classes. Adding public properties in IronPython class. Using classes/interfaces in IronPython class w

Another Awesome Collection - IronPython Links

A selection of IronPython and Dynamic Language Runtime related web pages and blog entries. Getting Started with IronPython John Cook makes a start with IronPython. This means using one of the three distributions available from the Codeplex homepage: the source code, the prebuilt binaries or the msi installer. IronPython is a One Way Gate Having got started John Cook is disappointed that he can't use Python C extensions from IronPython, and finds it hard to call into IronPython from C#. The answer to the latter problem is to use the IronPython hosting API , and John Cook has written another blog post on the former problem which will get an IronPython-URLs entry all of its own. NaroCAD to have support for IronPython 2.0! This seems like an exciting announcement, but is short on links to find further information. The upshot is that NaroCAD has, or will shortly have, support for scripting it with IronPython 2 and possible IronRuby as well: This means that with minimal change right now

Herding Code Episode 37

Herding Code is " a weekly podcast with K. Scott Allen, Kevin Dente, Scott Koon, and Jon Galloway ". They have a .NET focus, and episode 37 is an interview with Jon Udell - who is a technical evangelist for Microsoft and a Python / IronPython enthusiast. Herding Code in Episode 37: Jon Udell This week on Herding Code, Jon leads a talk with Microsoft Technical Evangelist Jon Udell, about strategies for Internet citizens. That is, making public information available for retrieval and manipulation through structured data feeds and Internet standards. The group discusses related topics like digital identity and OpenID and shares their thoughts on Oslo, DSLs, dynamic languages like IronPython.

Jeff Hardy Reviews IronPython in Action

Jeff Hardy is the creator of NWSGI . This is a .NET implementation of the Web Server Gateway Interface protocol; a Python protocol for web applications. His goal is to be able to use Python applications and frameworks like Trac and Django from IronPython with the Microsoft IIS server. He also blogs about his progress in getting Django and setuptools to run under IronPython. As with other recent entries on this news blog, he is featured here because he has posted a review of IronPython in Action : IronPython in Action Review He says: I wasn't really sure what to expect when given this book. Having read it, I now see that it is exactly what it says it is – IronPython, in action . For any serious work with IronPython (more than just using it as an alternative Python interpreter), than this book will save you a ton of learning time. The examples are clear, concise, and – most importantly – realistic. Even if you already know Python and .Net inside and out, but are new to Iro

Using Nose with IronPython

nose is a testing library for Python. nose is a popular alternative to unittest , which is part of the standard library, and boasts features like: Test autodiscovery Output capture Not restricted to class based tests Class and module level setUp and tearDown Assert introspection Test generators Plugin mechanism Personally I don't find the object oriented way of organising tests a problem; test methods grouped in classes seems very logical to me. I also like assert methods and the richer error messages they provide. I usually end up defining all sorts of convenience assert methods myself that do the heavy lifting of my testing anyway. I'm sceptical of the magic that libraries like nose and py.test do to provide some of the same information with bare asserts - and that magic doesn't work with IronPython anyway. The test discovery stuff is invaluable though. Whenever I create a new project I inevitably end up recreating some variation that does test discovery for the project

Writing an IronPython Debugger

One of the things that programmers in static languages complain about working with dynamic languages is the lack of tools. Many of them are unaware of the tools that are available for languages like Python: A plethora of Python IDEs and editors exist; with good support for syntax highlighting, autocomplete (intellisense), call-tips and all the features you expect from an IDE. Good ones include: Wingware Wing IDE (which includes a very powerful debugger) Activestate Komodo IDE Eclipse with PyDev Stani's Python Editor (free with integrated debugger) Netbeans and Python Many more including the old warhorses Emacs and Vim; beloved as lightweight companions to lightweight languages (and easy to integrate with the other tools listed here) Code coverage tools: coverage.py The debugger included with Python: pdb The profiling tools included with Python: profile library Refactoring tools: rope , Bicycle Repair Man Code quality tools: PyFlakes (fast), pylint (comprehensive), pychecker (i

An IronPython on Silverlight Collection

A collection of links about using IronPython with Silverlight, the Microsoft ' flash killer ' browser plugin. DLR + IronPython + Silverlight in 5 Steps (with pictures) A post by the MetaDeveloper to get you started developing Silverlight applications with IronPython and the Silverlight Dynamic Languages SDK . It includes the development process using Chiron. State of the DLR for Silverlight Whilst we're talking about the Dynamic Languages SDK for Silverlight, it's time for a word from the guy responsible for maintaining it: Jimmy Schementi. This is a long post that describes the SDK and answers some Frequently Asked Questions on the subject. The post starts with: It would seem the next release will be focused around REPLs, testing, scripting support, and maybe some server-side integration pieces. And you’d be right. Proof is in the project’s public source code repository. And ends with: I hope that made some things clear; the DLR, IronRuby, and IronPython are committed

Searching for Tweets with IronPython

Posts by Saveen Reddy have featured regularly on this blog, most recently his series of posts on automating Visio from Powershell and IronPython . He is back, and this time he is having fun with the Twitter Search API , using IronPython to search for tweets. IronPython: Searching for Tweets This simple example shows you how simple it is to search for tweets using Twitter’s Search API. Key techniques demonstrated in this sample code Using System.Net.WebClient to download a file Searching for nodes in System.Xml using namespaces Simple ATOM-feed parsing

Writing to Freebase with IronPython

Freebase is "A social database about things you know and love". It has a public API to access and update structured data. The API is based on the Metaweb Query Language (MQL) and naturally there are Python bindings to the API. The API Guy has a blog entry about writing to Freebase using IronPython, including code samples: Writing to Freebase with IronPython My mom was in town visiting this weekend, and when I went to demo Freebase for her, I asked her to name a famous person. She suggested Pope John Paul II , so we looked him up. Most of the information that you would expect Freebase to know about him, it did. But there was one glaring omission: it didn’t know that he was Catholic. Since Freebase knows 263 people who have ever been a professional Pope , I decided that it would take a little too long to update them each by hand. And so I set out to scribble up a few lines of Python to use the Freebase API libs for Python. In order to use the Freebase Python lib from IronPyt

Resolver One 1.4: One Day Special Offer (66% off) and Unit Testing Spreadsheets

Resolver One 1.4 was released a while back, and we have some great new examples. These include integration with the R statistical language, embedding the Resolver One calculation engine into IronPython programs, unit testing spreadsheets and using Numpy inside the spreadsheet. I was going to leave posting on all of this for a few days (still working my way through the backlog - I figure by now that the backlog is permanent though), but we have a one day special offer for Resolver One. 66% off ($75) on March 17th 2009 only. If you've been considering splashing out on Resolver One, now is the time to grab it: Resolver One: One Day Special Offer For those who have absolutely no idea what I'm talking about, but somehow still carried on reading this far, first of all thanks. Secondly, Resolver One is the .NET and Python powered programmable spreadsheet created by Resolver Systems . Resolver One has the largest known codebase of IronPython anywhere (around 40 000 lines of code in pr

Winforms with Mono and IronPython Tutorial Series

IronPython runs great on Mono, and if you use the official Mono installer then IronPython is included out of the box. (Although the version of IronPython 2 is quite old now and could really do with being updated - when I tried it the latest Windows binary worked fine on Mac OS X which isn't something you hear often. For Debian and Ubuntu users it is as easy as apt-get ironpython .) So cross platform application development with IronPython is really possible, and for client applications Windows Forms is the GUI toolkit to use. Although it looks ungainly by default on non-Windows operating systems, with customization it is possible to create applications that look great on Windows, Linux and the Mac. Up on ZetCode there is a 12 part tutorial on creating applications with IronPython and Windows Forms on Mono. It covers the basics, plus dialogs, advanced use of controls, drag and drop and handling painting yourself. It even creates Snake and Tetris applications as examples! Anyway - lo

Another Awesome Collection - IronPython Links

Another tab closing session - a lot of links to IronPython (etc) content here. There are a couple of interesting reports of Python libraries working with IronPython, but we start with an IronRuby article: .NET Interop: Getting Started with IronRuby and RSpec, Part 1 An excellent article by Ben Hall on testing .NET code (C#) with IronRuby and RSpec. In this article, I will introduce you to Ruby and IronRuby and demonstrate some basics of Ruby interoperating with Microsoft .NET Framework-based code. I also explain how frameworks such as RSpec can be used to generate examples of how objects are intended to behave, providing both documentation and verification that the system is built correctly. This will set the stage for a future article in which I will explain acceptance testing in detail and demonstrate creating acceptance tests with IronRuby. IronPythonの特徴 A Japanese article on IronPython. No idea what it says! Dynamic Language Runtime on Azure A demo of an Azure (Microsoft cloud pl

IronPython at PyCon and the Python Language Summit

PyCon 2009 - the international Python conference in Chicago - is rapidly approaching. Harry Pierson (Microsoft IronPython Program Manager) has blogged about how IronPython features this year: IronPython at PyCon Michael Foord and Jonathan Hartley are running a Developing with IronPython tutorial . Michael is also delivering a talk Functional Testing of Desktop Applications . Jim Hugunin is delivering an invited talk IronPython: Directions, Data and Demos Dino Viehland is sitting on the Python VMs panel and doing a talk IronPython Implementation Sarah Dutkiewicz (aka Coding Geekette) is doing a talk Pumping Iron into Python: Intro to FePy Harry also mentions the difficulties he's had in getting the Microsoft Gold Sponsorship for PyCon actually into the hands of the PSF. (Python Software Foundation - who as well as running the conference also own the copyright on the Python code and the trademarks etc). As well as talks on tutorials covering IronPython, PyCon starts this year with

Get in the Queue, your locks don't work here

Threading, locking and concurrency are all hot topics at the moment. One place where threading and locking don't work as a way of controlling access to shared resources are in distributed web applications. This blog entry by Tarn Barford discusses the use of Queues from IronPython (with plenty of example code) when working with web apps on the Azure platform. Get in the Queue, your locks don't work here I am, of course, talking about a pattern in high scale web application design, Queues. More specifically the Queue service on the Windows Azure cloud computing platform. So when do you use Queues? Its common to use thread synchronization objects in a web application to serialize access to a resource, but this thread synchronization approach doesn't work so well when you have multiple applications, over multiple servers competing for exclusive access to a global resource. The first scenario I've found which suits the Queue service is in a user driven content ranking syste

A Multilanguage REPL (and hosting IronPython in IronRuby)

REPLs (Read Eval Print Loops - interactive programming environments) are all the rage in Redmond these days, and Tomáš Matoušek (core IronRuby developer) isn't immune. This blog entry uses the DLR hosting API to create a multilanguage REPL using IronRuby. This demonstrates hosting multiple DLR languages in a single application (using the app config file) and hosting IronPython in IronRuby. Multilingual REPL DLR Hosting API is a common API for all DLR languages: IronRuby, IronPython, and others. It abstracts away language specific details and provides API that could be used in a language independent manner. The API is primarily designed to ease usage of dynamic languages from strongly typed .NET languages and to make it easier to write applications with a scriptable object model. Nonetheless we can take advantage of the API in a scripting language as well. For that purpose the most interesting features are management of isolated scripting environments (script runtimes) and cross lan

IronPython in SharpDevelop

SharpDevelop is an open-source .NET IDE for Windows. (The cross-platform Mono .NET IDE MonoDevelop started life as an early fork of SharpDevelop.) Features of SharpDevelop include: Support for Mono Supported languages include C#, VB.NET, Boo, IronPython and F# IDE features like refactoring, code completion, Windows Forms designer Can run from a USB device Read only projects Parallel build support for multi-core machines Multi-framework targetting (.NET 2.0, 3.0 and 3.5) Integrated support for tools like FxCop, Wix, NUnit, TortoiseSVN, MSBuild etc Of course on this blog it is the IronPython support that we are interested in. Back in 2007 Matt Ward blogged about the IronPython AddIn Internals , and some of the features it included. Now that SharpDevelop 3 is out, the support has matured and Matt has done a new blog entry showing how to use the Python standard library with SharpDevelop 3 and IronPython 2: Using the Python Standard Library with SharpDevelop

Make your .NET application extendible using DLR : IronPython

Krishna Vangapandu has posted a blog entry on using the Dynamic Language Runtime hosting API to make a .NET (C#) application extendable: Make your .NET application extendible using DLR : IronPython There are different ways to define this – extensibility in applications, adding macro capability to your applications, providing add-in like facility in .NET applications. For me, all of this mean the same – ability to modify your application (data or the UI) at runtime by means of scripts. Like I mentioned in the previous post, I wanted to dig into DLR or Dynamic Language Runtime which is basically a framework that could be used to provide dynamic languages support on the .NET platform. Even though I am not much interested in giving up C# for dynamic languages like Python or Ruby, I was very much keen to add facility to make my applications extensible using these languages (to tell you the truth, I am more comfortable with JavaScript or Groovy than any of these). Anyway, I worked on an appl

Rob Oakes on IronPython in Action and Learning to Fish

The manuscript for IronPython in Action is on the way to the printers. In the meantime Rob Oakes has been reading IronPython in Action (the Early Access version) and has posted a review online: Rob Oakes Reviews IronPython in Action He has a very interesting reaction to the book. He does seem generally positive, here is his final conclusion: In case it isn’t clear, I heartily recommend that anyone interested in learning Python or .Net purchase this book. It certainly has its idiosyncrasies, but it still manages two roles very successfully: 1) introductory text and 2) reference manual. While novice readers (like myself six months ago) will find tremendous value in reading the book from cover to cover, more experienced hands will find value in skimming individual chapters. As someone who has written technical documentation, I can testify that such a feat is extremely difficult to pull off. What is unusual is that he took away something from the book that was quite unanticipated by Chris

Azure Table Storage from IronPython

Azure (meaning the color of a cloudless sky) is Microsoft's new cloud computing platform. Table Storage is the data storage API of Azure. It " offers structured storage in the form of tables. The Table Storage API is a REST API for working with tables and the data that they contain ". Here are two recent blog entries showing how to use Table Storage with / from IronPython: Using the Azure table store’s RESTful APIs from C# and IronPython A blog entry by Jon Udell: In an earlier installment of the elmcity+azure series, I created an event logger for my Azure service based on SQL Data Services (SDS). The general strategy for that exercise was as follows: Make a thin wrapper around the REST interface to the query service Use the available query syntax to produce raw results Capture the results in generic data structures Refine the raw results using a dynamic language Now I’ve repeated that exercise for Azure’s native table storage engine, which is more akin to Amazon’s Simp

Embedding IronPython 2 and the Dynamic Language Runtime

My series of articles on embedding IronPython have been updated for the latest version of the hosting API in IronPython 2. As well as being updated there are two new articles, an introduction and overview of extending a C# application with IronPython plugins and an example 'Scripted Turtle' application that allows you to draw funk images through Python scripting: Embedding IronPython 2 and the Dynamic Language Runtime (turtles and articles) One of the most impressive things about DLR based languages like IronPython and IronRuby is how easy they are to host in applications to add dynamic features. You can even host IronPython in IronPython , something that Resolver One makes good use of to provide a separate execution context for each spreadsheet. During the development of IronPython 2 the DLR was changing regularly and each new release seemed to bring breaking changes to the API. This means that most of the online examples, including my own articles, quickly became out of date

ISV Innovation: IronPython for the C# Developer

ISV Innovation are a Microsoft partner who do online training for a wide range of subjects. This includes a series of on-demand web seminars on IronPython and Dynamic Language Runtime related subjects: Part 2: IronPython for the C# Developer (60 minutes) The course trainer is Bill Lodin (Vice President of IT Mentors). The description is short but straightforward: " This session provides an introduction to the syntax of IronPython for the Visual C# developer ". This web seminar also links to related topics in the the Microsoft Dynamic Language Runtime for Developers Web Seminar Series: Part: 1 IronPython for the Visual Basic Developer Part: 3 Inside the DLR Part: 4 Implementing a Dynamic Language Part: 5 IronRuby for the Visual Basic Developer Part: 6 IronRuby for the C# Developer