This week's lab focused on debugging scripts in PyhtonWin. In the first script, one of the ways to determine the errors was to hit the check button to see if there are any syntax errors. If there are no syntax errors, then I ran the script. This shows an error and what line the error is on. After fixing the error, I ran it again. If it resulted in an error, I looked to see the type and on what line the error fell on. The result of the error free script prints the fields in the park shapefile.
|
Layer Details |
The second script contained 8 errors. To find the 8 errors, I used the Check button. The syntax was fine so I had to run the script to see what error occurred. Each time I found an error, I corrected it and ran the script again. Some of the errors consisted of a bad backslash, wrong file format, missing spelling or words, and fixed the data source. The result of the script prints all the names of the layers in the data frame.
|
Layers in the Data Frame |
The third script contained errors. For this script, I added a try except statement to print the errors for Part A and have Part B run successfully. In order to do this, I had to find the errors by running the script. Once I found one error, I put the try-except statement before the line that contained the error. I ran the script again to determine the other error. I used the general exception to print the errors. Part B then successfully ran. The result of the script prints the errors in Part A and prints Spatial Reference and Map Scale.
|
Try-Except Statement |
The flow chart illustrates script 1.
|
Flow chart of Script 1 |
No comments:
Post a Comment