lørdag den 23. juni 2007

Python - first impression

I've tried out some Python now and it is really intriguing.

One of the first thing you meet is the interactive interpreter. Now, I've come across similar things before, like a javascript shell or even, well, an OS shell.
But in Python this is really how everything works.

Atop of the very interactive programming possibilities, the language is very intuitive.
Like this little snippet, which is how I'd like to write boolean statements, but can't in java for an example.

>>> x = 10
>>> if 0 < x <= 10:
... print "true"

In Python, list is a built-in type. If I want to perform a common action like arranging two lists into a set, I do not have to bother with much complexity. As shown.

>>> listKey = range(5,15)
>>> listValue = range(10)
>>> zip(listKey,listValue)
[(5, 0), (6, 1), (7, 2), (8, 3), (9, 4), (10, 5), (11, 6), (12, 7), (13, 8), (14
, 9)]

Not quite clear from the code, but the printout is a list of 'tupple' all of which are built-in types.

I will try to implement the 'stamp' program, for seeing how little complexity I will have to deal with.

Coming up; "The Stamp/Python tutorial"