Module 2 - Python Fundamentals Part 1



In this week's lesson, we covered some of the fundamental features of Python scripting, specifically differentiating between different data types and structures; using strings, numbers, variables, and lists; writing statements and expressions; and working with objects, functions, methods, and arguments. Knowing the proper syntax for writing code in Python is essential to be able to successfully execute geoprocessing scripts in ArcGIS. In essence, this is achieved by assigning different types of variables (such as strings, lists, integers, and floats), and then manipulating these variables by using functions, methods, and operators. 

Our reading assignments and lab exercise were very thorough and hands-on in showing us how the different combinations of code operates. A lot of material was covered, and it was a bit scary to know that people (programmers) actually have this stuff memorized in their brain. But just like learning any language (even the spoken ones), practice and exposure makes perfect. As Zandbergen states in Chapter 4, "There is no need to memorize all these methods." Resources are available at the tip of our fingers to make Python programming a smooth learning experience, such as 1. the auto-completion prompts in Python IDEs, which can be very helpful reminders of proper syntax, and help avoid making typos, 2. the Python Library Reference at http://www.python.org, and 3. the Help Window in the ArcGIS Python window.

Our lab assignment was pretty neat. We synthesized the concepts covered in lecture to write a short script manipulating and measuring a string: my name.  All in all, my script's ultimate task was to print my last name from a list using indexing, and print the value of a multiplication operation based on the length of my last name (the screenshot of my results are above). Other than making my head do some somersaults, a valuable lesson to take away from this assignment was that if another person's name were to replace my name in the script, the code will work as well. It was a very cool feeling when I finally made all my components run correctly, and actually understood what I was creating. :)

Comments