Friday, April 24, 2009

The Not English Edition

Four blog posts on IronPython in Japanese and Chinese containing interesting code examples.
This Japanese blog entry shows two code examples for working with environment variables. The example for Python (CPython - the 'standard' implementation of Python) uses the os.environ, although the code shown should work fine with IronPython as well. The IronPython example uses the .NET class System.Environment to access environment variables and System.IO.StreamWriter to save data to a file.
This Japanese blog entry starts with a brief example of Python syntax and then a fairly complete example of embedding IronPython 2 in C#. It includes setting up the DLR classes (engine and execution scope etc) and then accessing Python variables by type, pulling a Python list out as an instance of IronPython.Runtime.List.
Extension methods are a statically typed version of monkey-patching for .NET languages; allowing you to add methods to types by defining static methods. They don't (currently) play well with IronPython, although there are workarounds explored by Saveen Reddy in these blog entries. This Chinese blog entry illustrates the differences with a nice big diagram.
A very interesting entry using IronPython to programmatically post to a Wordpress blog using the XML-RPC API. The code shown is very simple and uses two assemblies: SharpLab.XML-RPCLib2.dll and SharpLab.WP-XML-RPCLib2.dll. The core class seems to be WordPressClient. As far as I can tell this is code that accompanies what was actually the first book on IronPython (albeit in Japanese): IronPython - Windows Script Programming. (Although that assumption is likely to be wrong given that the blog this post is on is called SharpLab. I couldn't find a download link for those assemblies those.)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.