This week’s assignment focused on diagnosing errors and debugging scripts. We learned several different types of errors and techniques for identifying errors and debugging, notably using try-except statements.
We were given 3 error-filled scripts to fix in IDLE. For the
first script we had to identify and correct syntax errors. I fixed the first
one easily but got stuck on one for quite a bit. Without giving away the answer, I was stuck
trying to figure out what was wrong with the variable for quite awhile before
realizing I was misunderstanding how the words in a loop worked.
I was able to work through most of the errors in the second
script methodically but ultimately, I ended up with the script running and
giving me the appropriate output, but still giving an error. This took a
while for me to resolve and after trying several things that only made the
script not run, I realized that it was because I still had the script open in
ArcGIS Pro. Once I closed the program the script was able to run and give me
the requested output.
The third script required us not to directly fix the error
but to add a try-except statement that allowed the script to run but to print
the error instead of terminating the script. I was able to quickly identify
where the issue in the script was and where to put the “try” statement but had
a more difficult time figuring out where to put the “except” statement. I ended
up adjusting my statement multiple times before I was able to get the desired
result. The following flowchart shows the steps I took to debug this particular code.




No comments:
Post a Comment