Monday, October 8, 2007

Lab 2

Lab 2 wasn't too bad. It took me a while to figure out how to use the json object in python since I couldn't find any documention on it. So I opened up the python source code and found out that it has a member called 'items'. I looped through them setting the correct variables of my templates. I must say that using templates is really nice. I used an idea template for the ideas, which made the code much easier to read since I don't have html stuffed in.

I did run into a problem with Python. I tried using exceptions to catch errors; for example, if the user entered a non-existing domain name. For some reason 'finally' caught everything even if no error occurred. I tried using 'break' in the 'try' section but 'break' is only for for-loops. So, does anyone know how to use exceptions appropriately in Python? Well, I just ended up using an if statement. If my webfileOpen() couldn't find the file it just returned None. If the calling method got 'None', it would return "NOT FOUND" message.