Exploring IronPython

  Earlier today I downloaded IronPython, and I've tested it out a little bit. The command line interpreter is nice and works pretty painlessly whether you are compiling the source or just executing the binaries. Python is a great language IMHO. Just like every language that has ever been written, it has a few problems. Python emphasizes short readable code.

IronPython's interpreter, ipy, allows interactive sessions as well as execution of files. It acts very similarly to Python's Official interpreter, IDLE. This makes transitioning easy for someone who already knows how to program using the Python language.

I sat down and took a couple of seconds writing a simple fibonacci number program to print out the first 10 fibonacci numbers as an example of how Python code is used.

 

def fib(number):
    if number == 0:
        return 0
    elif number == 1:
        return 1
    else:
        return fib(number-1) + fib(number-2)

def main():
    for i in range(10):
        print fib(i)

main()

 

If this code is in the file fib.py I can execute it using the following command.

ipy fib.py

It generates the following output.

 

0
1
1
2
3
5
8
13
21
34

People have integrated IronPython into Visual Studio as well, and I'll soon look into doing that as well. I like how simply and easily I am able to create this little program. Now with IronPython I also have access to the .NET Framework's libraries.

Comments