:-$

Ryan's work blog

My Links

News

The WeatherPixie
Subscribe with Bloglines
About this blog

Tools I use:

Post Categories

Article Categories

Archives

Image Galleries

Blog Stats

Personal

Projects

Random Blogs

Random other

Reference

Web comics

Work

Python, how you tempt me so.

While Nathan and Russ are investigating Lisp, (see nathan's examples) I've been looking into Python. So far, I really like what I see.

I've been slowly reading an excellent Python tutorial, and have come across some neat things:
  1. Whitespace and indenting to represent structure. instead of:
    if(cond){
      things();
      to();
      do();
    }
    
    you have:
    if cond:
       things()
       to()
       do()
    
    We put everything in that structure anyway, since thats the most readable way to code things. Why bother with the parentheses and brackets if we already represent the structure with new lines and indenting?
  2. Multiple assignments:
    a,b = 1,2
    
  3. The "in" operator:
    if x in (1, 2, 4):
      doStuff()
    
    That's an operator I've been wanting for years. Instead we end up having to write:
    if(x == 1 || x == 2 || x == 4){
      doStuff();
    }
    
    And, of course, we don't have magic numbers but named constants or Enums being cast as ints, which gets very long and harder to read.
From what I've seen so far, Python looks like a really nice language. I'm going to try to write a mandelbrot set generator (complex numbers are handled automatically, no need to define my own class) and compare it to one I've already written in C#. Then I want to try it with IronPython, a Python implementation for .NET. If that works out nicely, then we might try to implement some things in a mix of Python and C#.

posted on Thursday, August 05, 2004 5:12 PM