|step over button|
The second script was supposed to print out the names of all layers in each data frame of the Module4/Data/TravisCountyAustinTx.mxd map, but it too had eight errors/exceptions. Using the tools above and going line-by-line, I found all eight errors and was able to run the script:
The third and final script had a Part A and Part B. Part A had an Exception we were not to fix. Instead we would use the try-except method. The script was intended to run Part A; encounter an error; and print an error statement; Part B would run successfully, printing out the Name, Spatial reference, and Scale of the data frame.
There were many steps I used to complete script 3. Below are the steps I followed to apply the try-except statement:
1. Initially, I ran my code normally, not using the Debugger tool, to see what error was present.
2. After I detected which line of code had an error, I reviewed the try-except portion of the lecture video.
o I was concerned with the placement of the try- except block of code.
o After reviewing both the video and the text book, I had a good idea of where to place my try-except code
3. Initially, I placed the block of code before and after line 13 (mapdoc = arcpy.mapping.MapDocument() )
4. My challenge was to determine the, beginning and ending points for the try-except block of code, so I used a line-by-line approach until I got my script to run correctly.
My lesson learned was to take note of the blocks of code as each step or function relates to its placement in the PythonWin window. I found it helpful to add empty lines between each action in the script as I used the step-over function.