Squash The Bugs (GIS4102- GIS Programming)

Module 4 introduced us to Debugging, a very important concept for Python. Errors are bound to occur, so successfully finding and correcting them means the script will actually run! The lab had three parts and three scripts that needed to be debugged.

















The first script given contained two errors. These were found within the script and corrected, with the results printed. The results are the names of all the fields in a shapefile called parks.












The second script was a bit more tricky in that it had eight errors. What needed to be fixed were the modules, functions, and arguments. Once fixed, the output displays all the layers of each data frame from a given mxd.









The third and final script involved two parts, A and B. Part A contained an error which we wanted to display using a try-except statement. This would display the error, while part B would successfully run, giving the spatial reference along with the map scale.

This assignment was challenging but definitely manageable. It takes time to learn how to sort through the code and find the errors. Some will jump straight out like syntax errors, others require much more thought and persistence.

Comments