Learning Python

Learning a new language is always a bit stressful. I thought that I would learn python; I need a new, rapid development, build some scripts, but don’t look as awful as perl type language. I’ve recently learnt lua which was fun, but then it’s meant as a very small, quick langauge. It’s nice, but not really the perl-u-like that I wanted.

I have actually been through the process of learning python in the past; I used to generate my website with ht2html which was quite cute and did the job; it was written in python, and I needed some skills to fiddle with it’s output. In the end, I decided that table within table presentation was not ideal and that CSS was the way to go, so I moved to muse which I still use nowadays.

As always, learning a new language is frustrating as you realise that you don’t know how to do even the most elementary things, and bugs are a nightmare to hunt down. Simon has been helping me lots with some of the my more “I’ve really screwed this up question” and I now have a version working version of my literate owl system. I’ll post the results of this soon; there are a few tweaks that need to happen first.

Along the way, I came across a very wierd problem. My script was failing totally; it always appeared to crash with a syntax error. It took several seconds to do this and, at the same time, the mouse cursor changed into a cross. I came across a thread which looked like the same thing, but in a totally different setting. The cause? Well, my script was…


#/usr/bin/env python


import re
import sys

def main()
    TheProgramHere()

The problem is on the first line; the second character should be !. Without this the script is interpreted my BASH; import is part of ImageMagick. I finally worked out what was happening when I found two large files, one called “re” and one called “sys” in the local directory. Computers can be irritating at times.