Lab 1 [GIS5103]: Introducing Python

The screenshot above provides the result of running my first Python script (based on Python version 3.6.8) to automatically generate folders that will be used this semester for organizing the data, scripts, and results in each module of GIS5103 GIS Programming. One of the main take-aways from the lab this week was interpreting "The Zen of Python", written by Tim Peters, which I summarized as follows:

"The Zen of Python" provides 19 guiding principles to consider when writing Python code. A recurring theme across the principles is that LOOKS MATTER – we should strive to write code that is easy to decipher and read. If there is a simple versus clever way to write the code, we should stick with the simple and explicit version, and we should follow this principle with each line of code (i.e., multiple lines of code that are easy to read are better than one complex line). We should also choose variable names that make reading the code easier (e.g., use a variable called radians instead of a variable called rad). Similarly, we should use indentation, blank lines, and documentation comments meaningfully to chunk the major steps in the code. Finally, we should consider long-term maintenance of the code (by ourselves, and by others). In this regard, we should be methodical with debugging with the first released version. Debugging shouldn’t be considered a guessing game – instead, it should be conducted to find the exact reason for any errors. We should also strive to fix any errors we find exist (even when we could ignore them for the current version of a program)."
This week we also compared two script editors (IDLE and Spyder) that can be used to write and debug Python programs. Spyder has a greater suite of options (including a code debugger) and will be the preferred editor of choice in this course. A preliminary exploration of the interface for this tool while running a script indicated that the Editor Pane and Variable Explorer Pane are easy to use, with coloring and formatting that helps to easily identify Python constructs.

Comments

Popular posts from this blog

Lab 2 [GIS5935]: Data Quality Standards

Lab 5 [GIS5935]: Surface Interpolation

Final Project [GIS6005]: Conservation in the State of Florida: Preserving Key Habitats of the Striped Burrfish