Welcome to AspAdvice Sign in | Join | Help

Orcs Goblins and .NET

I enjoy reading and writing. I hope you enjoy at least the former.

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.

Sponsor

Published Tuesday, November 27, 2007 11:23 AM by Brendan

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Exploring IronPython @ Tuesday, November 27, 2007 12:25 PM

I'm glad you're having fun with IronPython. For the record, IDLE is a graphical IDE and not at all like the interactive interpreter. The default Python interactive interpreter is very similar to 'ipy' though - so you're right it is an easy transition. Here are a few resources you might find useful: http://www.voidspace.org.uk/ironpython/index.shtml

http://www.ironpython.info/

Oh - plus my fledgling book! :-)

http://www.manning.com/foord Michael

Michael Foord

# re: Exploring IronPython @ Tuesday, November 27, 2007 12:49 PM

Thanks for the resources Michael. I will check these out.

Brendan

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below