Wednesday, July 17, 2013

Debugging and Error Handling


This week's assignment covered debugging and error handling.  This is a topic that is useful in any form of programming, not just when writing GIS scripts.  Our first exercise (above) involved correcting some syntax errors in a simple script that reads out the names of various airports in a shapefile.  Nothing too difficult here and the IDE that I use (PyCharm) helps point out many of those errors.


The second part of the assignment similarly needed corrections.  This script used some of the functions we learned last week in the Map Scripting module, so it was interesting to try to find the syntax errors in that code which we've not used much.


Finally, the grads had the chance to implement a couple try-except statements on code that contained errors. We didn't fix the errors, but implemented the try-excepts so that the code would still run, even if it ran into a problem.  This is a super useful tool to have as the exception can return good information about the error and prevent things from running off the rails entirely.  

Overall, a good week, lots of useful tools for the toolkit.

No comments:

Post a Comment