Posts

Showing posts from February, 2009

Blogpingr goes GUI

Blogpingr is a Python command line tool for pinging xml-rpc services when you write a new blog entry. Norman Kosmal has been playing with IronPython, so he decided to use it to give blogpingr a GUI: IronPython: Blogpingr goes GUI Now diving into IronPython I decided to give blogpingr a GUI. I am lazy, just so you know and using a shell to execute the programm got me bored. Also this probably is a good oportunity to check out how you can use window forms from within IronPython. Of course credit goes to Borislav Gizdov`s for coming up with blogpingr in the first place. I just hooked his code into IronPython structures. I still got to add threads to this programm so the methods won`t lockdown the textbox on execution. Maybe I will add some inplace editing functions to add, edit or remove rpc servers from the .conf file. Once that is down I will release the source on this blog. So stay tuned for updates.

Writing Xml with IronPython, XmlWriter and the 'with' statement

One of the best things about IronPython 2 is that it is based on Python 2.5 rather than 2.4. Amongst other goodies this means that the with statement is available. The with statement is the equivalent of C#'s using statement , although the Python context management protocol methods give a finer degree of control over exception handling. The with statement makes resource initialization and clean up simpler, and it will be nice to start using it throughout the Resolver One code base. It can often be used to replace the use of decorators or explicit try finally blocks, and many objects in the Python standard library have the necessary context manager methods to be used with "with". Luis Diego Fallas has written a great blog entry demonstrating 'with' with the XML classes provided by System.Xml : Writing Xml with IronPython, XmlWriter and the 'with' statement He creates a small wrapper class that provides the __enter__ and __exit__ methods used by the

Apress: Pro IronPython

IronPython in Action is on its way to the printer, and when it is finally available in real paper in about 4 weeks (final ebook available any day now) it will be the first English book on IronPython. Various other publishers have been asking around the IronPython community for a while now (including O'Reilly which is ironic given that after promising to come back to me I never heard anything more from them when I first pitched them 2 1/2 years ago - ha! I've been very happy with Manning though and so glad things went the way they did), and finally Apress have announced an IronPython book. In the interests of balance (despite managing to make this blog entry entirely about my book so far) here are the details: Pro IronPython IronPython represents a unique direction for developers interested in working with dynamic languages within the .NET Framework. Whether you’re looking to develop applications from scratch or add functionality and maintainability to an existing application,

An IronPython Silverlight Bonanza

Silverlight 2 is the Microsoft browser plugin that includes a cut down version of the .NET runtime called the CoreCLR. Silverlight 2 runs on the IE, Firefox and Safari browsers on Windows and Mac OS X (Intel only). The Dynamic Language Runtime can run inside Silverlight, making it possible to natively script the browser with Python. Meanwhile, the Mono guys have been busy creating a Mono version of Silverlight 2 for Linux called Moonlight . Although Moonlight 2 hasn't yet been released, they are making great progress with it. The latest development version (build instructions here ) is capable of running some of my IronPython demos: Python in the Browser on Linux On my Silverlight pages I have a series of articles and simple demos of developing Silverlight applications with IronPython. This includes my Web IDE which is a great tool for interactively exploring the Silverlight APIs and comes with several different demos preloaded. Due to the minor trials of completing IronPython

web2py - a Python web framework that supports IronPython

At PyCon 200 Dino Viehland (core IronPython developer) demonstrated Django running on IronPython . This was very cool, but required minor modifications to Django 0.9.6. Since then Jeff Hardy has been working on getting the latest version of Django working with IronPython , but it isn't yet ready for the prime time. Meanwhile, web2py is a Python web framework (yes, another one) created by Massimo Di Pierro as part of a course he teaches on Python. Amongst other things, it is being used to run the PyCon 2009 registration system. The latest release of web2py is the recently announced 1.56 (56!?): web2py is OUT Included in the announcement is this: - Runs on Jython (although without db drivers) - Runs on IronPython (although without CSV, db drivers and internal web-server) As far as I know web2py is the first Python web framework to include IronPython support out of the box.

Python is the easiest language in which to do interesting things

Larry O'Brien is a .NET blogger who is a fan of IronPython and Resolver One . Larry is also a writer for the SD Times technology website. One of his recent articles is on Python, IronPython and Resolver One (amongst other things). It starts well: " Python is the easiest language in which to do interesting things ". Python: Arbitrarily Interesting As a .NET developer he naturally goes onto talk about IronPython and then discusses IronPython in Action . For fellow dilettante Python programmers, I recommend the book “IronPython in Action” by Michael Foord and Christian Muirhead. Soon to be published by Manning (I reviewed a preprint), the book is particularly strong in providing simple-but-not-simplistic illustrations and tables that clarify behind-the-scenes structural elements. Visual Studio screenshots may be a little more common than I’d like, but for those new to the VS environment, these may be welcome. The cheek , there's maybe four or five screenshots of Visu

Venturing into IronPython: SQLite and IronPython Studio

Mark Garringer has been venturing into IronPython and posted a couple of blog entries on his experiences. Mark has been trying to learn Python for a while, and as he is a .NET programmer he found it easier to get into IronPython. His first experiment is a Windows Forms SQLite Administrative UI using System.Data.SQLite . The blog entry shows the code: My first venture into IronPython The need for this arises because of the lack of built in encryption in SQLite. There are hooks for creating your own, which is what the people who make the ADO.NET Provider, System.Data.SQLite , did. What this means is that the standard SQLite3 command line utility won't open a sqlite database encrypted using the System.Data.SQLite provider. From what I understand, if I REALLY wanted to, I could get the Provider's source and make it so that the SQLite3 library was NOT compiled into the data provider then I could get the library and probably get an existing UI to use it and all would be fine. But w

The Problem Solver: IronPython in Action

Maurice De Beijer (the Problem Solver) is a Microsoft MVP, and one of the organisers of the Software Developer Network events in Holland. He has also reviewed a pre-release copy of IronPython in Action. Maurice De Beijer on IronPython in Action At the start of the review he explains his interest in Python: So why am I interested in a book about IronPython? Well I used to do some Python programming a number of years ago and found the language kind of nice to work with. Working with dynamic languages like IronPython relieves you from a lot of the code you have to write just to keep the compiler happy. The rest of the review presents a quick summary of the four parts of the book, with commentary. And his conclusion: This book is a good read for all .NET developers who want to know about the new trend towards the dynamic languages and IronPython in particular. You get a good explanation what IronPython can do for you and how to go about solving every day programming problems. With the cur

Ironclad 0.8.1 Released

Following hot on the heels of the 0.8 release, William has managed another update to Ironclad . Ironclad is an open source project by Resolver Systems which reimplements the Python C API to allow you to use Python C extensions from IronPython. He posted the following announcement: I'm fairly pleased to announce the release of Ironclad v0.8.1; it's not an enormous technical leap above v0.8, but it does now enables you to import and use SciPy and Matplotlib with IronPython on Win32 (with some restrictions; see project page). Downloads of the source and binaries, plus more details, are available at the Ironclad Google Code Project Page -- please do play with it, and let me know if you have any problems. It's a fairly momentous release; the reason that William is only fairly pleased maybe because the release has been eclipsed by him becoming a father! Congratulations William. The list of C extensions that have now been tried with Ironclad has now been extended to: numpy 1.2

YAAS 2 (Another Yet Another Awesome Selection)

Another blog entry accreted from only the finest selection of IronPython related blog postings from the last few weeks: A Simple DLR Binder This entry is notable because Dino Viehland (core IronPython developer) has finally written another blog post! This post is on writing DLR binders, a core part of creating dynamic languages that use the Dynamic Language Runtime. DLR binders define the semantics of your language, and Dino explains them along with some C# example code implementing integer addition: There’s a few key pieces you need to understand here. First you’re returning an expression tree back to the DLR to tell the DLR what to do. The DLR will compile this expression tree and run it. You’re also returning a set of restrictions. These will be evaluated by the DLR to see if it can re-use the same code for other objects in the future. You’re unlimited in what you can do with restrictions as they can be arbitrary Expression trees. But here I’m simply restricting based upon th

Visio from IronPython and Powershell, Parts II & III

Saveen Reddy posted recently on automating Visio to draw diagrams from the command line . He has followed this up with two more posts. Both posts use the Visio automation API from IronPython and Powershell, and have plenty of screenshots to show you the results of the interactive code examples he presents. Visio/IronPython/Powershell - Part 2 - Drawing Diagrams from Data This post discusses using data to generate your diagrams; specifically tabular, hierarchical data, and directed graphs: Draw some simple shapes >>> vi.Draw.Rectangle( 0, 0, 1,1 ) >>> vi.Draw.Oval( 2, 2, 3,3 ) >>> vi.Draw.Line( 4, 4, 5,5 ) Loading data from a CSV file exported from Excel. The interactive shell extensively uses System.Data.DataTable to store tabular data >>> data = ( ('Hello',1) , ('World',2) ) >>> datatable = ToDataTable( data ) >>> vi.Draw.Table( datatable ) create a CSV file in Excel And then load it as a DataTable and l

Consuming Extension Methods in IronPython Parts II & III

A while ago Saveen Reddy posted an entry on using extension methods from IronPython . Extension methods allow you to extend types and interfaces in C# by defining new methods in a * different * assembly. IronPython can only see these extension methods if they are decorated with the ExtensionType attribute. This is fine if you have access to the source of the extension methods to and can recompile with this attribute. In part II Saveen shows how you can make the extension methods visible to IronPython without having to modify the assemblies containing the extensions - by creating a third assembly: Consuming Extension Methods in IronPython Part II Part III does some weirder magic using the CodeDom. It allows you to activate the extension methods from inside IronPython without having to create the extra assembly used in Part II. Consuming Extension Methods in IronPython Part III The Isotope.IronPythonUtil is an assembly that contains a method CreateIronPythonExtensionMethodAssembly(

IronScheme 1.0 Beta 2 Released

There are three Microsoft developed languages that use the Dynamic Language Runtime: IronRuby, IronPython and a closed source language that only runs on Silverlight - Managed JScript. IronScheme is a 'community-developed' language that also runs on .NET through the DLR. IronScheme includes a Visual Studio plugin (for VS 2008 SP1) and IronScheme 1.0 Beta 2 has just been released. IronScheme aims to be a R6RS conforming Scheme implementation. IronScheme Homepage 1.0 Beta 2 Release Notes New in the 1.0 Beta 2 release: Added a new LINQ library (ironscheme linq2) which implements all methods found under System.Linq.Enumerable. The new version also uses deferred execution Added a few more libraries Added (ironscheme unsafe) library Many bug fixes Added P/Invoke functionality, and a small FFI layer Many compiler optimizations added (TCE, lambda body hoisting, assignment elimination), more coming for beta 3! Rewrote fixnums and flonums in Scheme. Uses unsafe features. Memory optimiza

Make Your Application Extendable Using the DLR

IronShay has posted an article on extending applications by hosting the Dynamic Language Runtime. He shows code for adding Python or Ruby scripting to an example Windows Forms application written in C#. Make Your Application Extendable Using the DLR It’s very common for applications to have a way to extend them. Extensibility comes in various ways and have multiple names too – plug-ins, add-ins, addons, etc. It seems, though, that one kind of extensibility was left to the very few – application macros. The concept is very simple – You don’t need to create a special Dll, implement a specific interface and register it somehow, you don’t even have to install an IDE. All you have to do is to open the relevant window, write some code and voila – you’ve extended the application. This sample is very simple but it took me about 20 minutes to get it done. It’s just magic!

IronPython and CodeDOM: Dynamically Compiling C# Files

Harry Pierson (DevHawk) has an interesting article on dynamically compiling C# from IronPython using CodeDom . His motivation for this is to allow him to use extension methods without tying himself into a dependency on a specific version of the DLR. IronPython and CodeDOM: Dynamically Compiling C# Files Of course, I could have simply re-compiled the assembly against the new bits, but that would mean every time I moved to a new version of IronPython, I’d have to recompile. Worse, it would limit my ability to run multiple versions of IronPython on my machine at once. I currently have three – count ‘em, * three * – copies of IronPython installed: 2.0 RTM, nightly build version 46242, and an internal version without the mangled namespaces of our public CodePlex releases. Having to manage multiple copies of my extension assembly would get annoying very quickly. Instead of adding a reference to the compiled assembly, what if I could add a reference to a C# file directly? Kinda like how addi

Bridge, Kamaelia and XMPP on IronPython

Kamaelia is a Python concurrency library that uses Python coroutines (generators). Despite being pure Python it is powerful enough for streaming audio and video. Bugs in IronPython 1 prevented Kamaelia running on IronPython, but that doesn't seem to be the case for IronPython 2... Sylvain Hellegouarch has a Python library called headstock for communicating over XMPP: XMPP and IronPython 2 using headstock, bridge and Kamaelia For a while IronPython had severe shortcomings that prevented it running simple Kamaelia applications. Today I was able to run a simplechat demo using a vanilla IP2 on Windows with only one single modification to the logging module (thanks Seo). To be honest I didn’t expect it to go through :) The chat demo is simple enough but means more complex examples using XMPP PubSub will work as well (they are all based on the same framework). Now this isn’t production ready or anything. For instance the TLS support is broken (hopefully something easy enough to fix

Introduction to WPF with IronPython

Windows Presentation Foundation (WPF) is the successor to Windows Forms; a powerful user interface library for .NET. Where Windows Forms is built on GDI/GDI+ for drawing the GUI, WPF is built on DirectX. This means that much of the work can actually be done on the GPU (the graphics card), and so despite being richer and easier to theme WPF can perform better than Windows Forms. Mark Bloodworth has been experimenting with WPF and IronPython: An Introduction to WPF with IronPython Having scanned a few pages, I decided to create a very simple app that included databinding and an event handler. Armed with Notepad++, XamlPad and a command prompt I set out. First step was a little C#. I created a class as detailed here that adds a little dynamic-ness to WPF. WPF is also used by Silverlight - which was originally called WPF/E - and is one of the few Microsoft projects to go from a boring codename to an interesting final release name; WPF itself was originally codenamed Avalon. WPF has a n

Visio/IronPython/Powershell – How to draw nice diagrams from the command line

Saveen Reddy has an automation project for working with Visio - a technical drawing package from Microsoft. The automation project allows you write extensions, plus use Visio from the command line: Visio Automatic Extensions . He's posted before on this project, for example his hello world in C#, F# and IronPython article. This entry provides lots more examples (with huge screenshots), this time on using the Powershell and IronPython interactive interpreters to drive Visio: Visio/IronPython/Powershell – How to draw nice diagrams from the command line Demo 1 – Shape formatting Python >>> vi.Start() Powershell vis> $vi.Start() This will launch a new instance of Visio 2007 that is bound to the Interactive session. When Visio launches this way a new doc will be created with a single empty page. It will also load the Basic Shapes stencil – the interactive session depends on this stencil being loaded. Draw some shapes in visio. Then select them all. The selection is

Python on Android with Mono and the DLR

Koushik Dutta has been working on porting Mono to the Android mobile platform, including a bridge that allows you to call into the Java APIs from C# and other Mono supported languages. Of course through the Dynamic Language Runtime, other Mono supported languages includes IronPython and IronRuby: Microsoft's DLR and Mono bring Python and Ruby to Android After copying the necessary DLLs over to the phone, I was able to run the simple ipy.exe console application that comes with the DLR source code. The neat thing I discovered while perusing through the documentation is that IronRuby and IronPython are actually compiled into CIL byte code and thus eventually native code! Anyhow, as you can see, IronPython is working dandily on the phone.

IronPython 2.0.1 Released

IronPython 2.0.1 is a minor update to IronPython 2.0 which in turn is a CPython 2.5 compatible release running on the .NET platform. The top priority for this release was improving upon performance while retaining backwards compatibility with IronPython 2.0. One of many notable areas we’ve improved upon is that float-integer comparisons are now 74% faster than they were in 2.0. A full report documenting changes in interpreter performance from 2.0 to 2.0.1 can be found at: Comparing IronPython 2 and 2.0.1 Performance A special thanks goes out to Resolver Systems for helping us in identifying areas needing performance improvements. You can download the new release from: IronPython 2.0.1 Download Page In addition to numerous bug fixes in our IronPython 2.6 branch that were backported to 2.0.1, we also fixed the following CodePlex bugs specifically for this release: 20632: can't write a __len__ returning a uint 20492: TupleExpression.IsExpandable is internal, should be public

ArcGIS (Geographical Information System) from IronPython

ArcGIS is one of the market leaders in the massive Geographical Information System software industry. Alex Willmer has been using the ArcGIS APIs from IronPython and written up the results of some of his experimenting: from ESRI.ArcGIS import Geodatabase On the desktop ArcMap is used to create map documents (.mxd file), whilst ArcCatalog is used to manage data sources. ArcGIS Server can (amongst other things) serve a map document, as a service for web client, Google Earth or remote ArcMap users. ArcGIS may be automated to an extent, through an interface known as ArcGIS Geoprocessing. But this covers only some cases, delving deeper provides much greater opportunities. ArcGIS is built on a COM object library named ArcObjects . Native ArcGIS files, such as an ArcSDE connection (.sde file) are the in memory COM object, serialised to disk as binary. It is difficult to edit or create such files in an automated fashion, without calling ArcObjects. So, like the Java code CreateSDECo

IronPython in Action Reviewed by Lawrence Oluyede

Lawrence Oluyede is a Python developer who used to do C# development and has also used IronPython . He has been reviewing IronPython in Action , and has posted summaries of all fifteen chapters in Italian as he has read them. You can read all of his summaries from here . He has now written a review in English. This also summarises the chapters, but is not as long as the Italian entries! IronPython in Action Book Review Recently I’ve had the opportunity to read Michael Foord’s upcoming book: IronPython in Action and let me say that I found it extremely interesting, and I suggest it to everybody needing (or wanting) to work with .NET from a dynamic perspective or to .NET developers interested in the world out there. The book covers a lot of ground, sometimes deeply, sometimes just in the surface but it seems to talk about everything there’s to know to make that ground solid enough to build something lasting. From the Python introduction to IronPython extension, from

Ironclad Screencast and NumPy in Resolver One

Following on from the release of Ironclad 0.8 it is now possible to run through the NumPy tutorial at the IronPython interactive interpreter. Resolver Systems also has exciting news about using NumPy inside the spreadsheet. We have a four minute screencast showing off both of these things: NumPy integration in Resolver One using Ironclad The screencast demonstrates using NumPy arrays of up to a million numbers inside the spreadsheet grid, with impressive performance despite being early days in the integration. For two dimensional arrays the grid is a natural representation; and multi-dimensional arrays can be sliced through the user interface. The spreadsheet part of the screencast uses the new beta version of Resolver One, which is built on IronPython 2: Do you want to try Resolver One 1.4 Beta? New features in version 1.4 include: We’ve moved over to IronPython 2.0. This brings you some immediate advantages, including bugfixes to the core scripting language, new supported core l

YAAS (Yet Another Awesome Selection)

I've nearly caught up with my backlog, but in the meantime there have been several selections full of smaller entries and snippets. Here's the first one. Batch converting Word documents to text Replace text within a Word document Two new pages on the IronPython cookbook showing how to use COM interop to automate Microsoft Word. IronPython как движок для макросов в .NET приложениях I've featured various non-English articles on IronPython before, but I think this is the first one in Russian. This article shows how to use IronPython to provide macros for C# .NET applications. The example shows Python scripts adding menu items to a notepad style app. I'm not sure of all the details, this is the best google translate could manage for part of the article: Create your tongue + interpretor to him with an opportunity. NET interoperability - non-trivial task, leave it for the enthusiasts. The code is all shown though, so it should be easy to figure it out. Tinesware - Python