Python Programming, news on the Voidspace Python Projects and all things techie.

Multiple Python Engines in IronPython

emoticon:clock Great news from the IronPython team:

I guess now is as good as any time to announce that we're going to support multiple instances of engines in a single app domain. I think we'll also have a spec that's in good enough shape to send out soon but I'm not quite sure when that's happening.

This is good news for Resolver. We use the support for multiple engines from IronPython 1, and its absence in IronPython 2 is one of the things that has blocked us from updating. The only thing blocking us now is that they haven't yet ported static compilation [1] from IronPython 1 to 2. Smile

Being able to host multiple, isolated, Python engines allows interesting possibilities - you can even experiment with it from within IronPython.

Incidentally, it is also good for the deployment of Rails on .NET with IronRuby.

[1]Allowing binary distributions.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-11-12 22:59:33 | |

Categories: ,


Python Properties and New Language Features in C# 3.0

emoticon:new_document Guido has just checked in an improvement to the way you create properties in Python. This will appear in Python 2.6 and 3. Currently in Python you can use the property decorator to create get only properties. C# actually has nicer syntax than Python for properties, something like:

class Something {

    private string _something;

    public string something {
        get { return _something; }

        set { _something = value; }
    }
 }

I've implemented the 'logical equivalent' for Python. It is very different to Guido's new technique, but is available today. It allows you to write:

class Something(object):
    def __init__(self, x):
        self.x = x

    class something(Property):
        def get(owner):
            return owner.x
        def set(owner, value):
            owner.x = value

The property is the inner class, with get and set methods.

I've written a new article (a blog entry that got way out of hand), that shows the new way of declaring properties, the implementation of Property used above, plus it discusses some of the new features in C# 3.0. Some of the new language features are just C# catching up to Python - but perhaps Python has something to learn from some of the others:

Getting LINQ into IronPython will be particularly interesting, as it would mean changing the Python syntax. LINQ is very powerful, but adding to any .NET language is non-trivial. Will we (the Python community) accept this - even if it is guarded with a __future__ import? Smile

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-11-11 20:51:35 | |

Categories: , , ,


LOLCODE! on the DLR

emoticon:black_hat Well, John Lam has gone and done it! He has released Martin Maly's implementation of LOLCode on the Dynamic Language Runtime:

HAI
CAN HAS STDIO?
I HAS A FISH ITZ "Yummy"
VISIBLE FISH
VISIBLE "HAI WORLD!"

I HAS A FIB
I HAS A A ITZ 1
I HAS A B ITZ 0

GIMMEH FIB

IM IN YR LOOP
  VISIBLE B

  IZ FIB SMALR 1?
  YARLY
    GTFO
  NOWAI
    VISIBLE "NOWAI"
  KTHX

  I HAS A TEMP ITZ A UP B
  LOL A R B
  LOL B R TEMP

  NERFZ FIB!!
KTHX
KTHXBYE

To get it running, you'll need to follow these steps:

  • Download the source

  • Download Gardens Point Parser Generator (GPPG) and Gardens Point Scanner Generator (GPLEX) [1]:

  • Update the LolCode pre-build event as described below

  • Update reference to ShiftReduceParser (part of gppg/gplex distro)

  • Download the DLR, which is part of IronPython 2.0 Alpha 6 (The binaries suffice for building LolCode, but getting the source code will let you build and debug through DLR code)

  • Update the references to the Microsoft.Scripting.dll in both Lc (console) and LolCode (compiler) projects

These instructions are included in the LOLCODE distribution. Smile

[1]The parser is generated using Gardens Point Parser Generator (GPPG) and the scanner is generated using Gardens Point Scanner Generator (GPLEX). Both these tools are developed by QUT Australia.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-11-11 12:23:05 | |

Categories: , ,


Hosted by Webfaction

Counter...