GIS5103 Module 1: Python Environments & Flowcharts
The first week of GIS Programming touched on a brief introduction to the Python programming language and how to think algorithmically with the use of flowcharts. A few notes of interest:
General
- Command Prompt not the same as Python Command Prompt
- “dir” – basically tells computer/Command Prompt “What is in the directory?”
- Python is an interpretive language, NOT a compiled language
- IDLE = Integrated Development Learning Environment – book refers to as Integrated DeveLopment Environment, however
- Usually do script in file and send (“Run”) to do interpretation
- Workflow = flowchart
Python in ArcGIS Pro
- TWO ways to launch Python in ArcGIS – (either will open new Notebook)
- Method 1: Insert Tab -> “New Notebook” (in Project group)
- Method 2: Analysis Tab -> “Python”
- Notebook consists of cells
- To run CURRENT cell being written in, hit Ctrl + Enter OR click “Run”
We used https://app.diagrams.net to create a flowchart using the basic formula for converting radians to degrees: degrees = radians*180/pi
This module also requested we interpret "The Zen of Python" by Tim Peters:
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
My interpretation of “The Zen of Python” (above) is that it is a little bit of commentary on society and the subjectivity of society values (“Beautiful is better than ugly”) and bits of human advice - but mainly expresses the overall expected structure of the Python language. This poem by Tim Peters seems to indicate what is the best way to write Python code, and what are the practices for writing in a way that is clearly understood by the interpreter/machine. Lines such as “Readability counts”, “If the implementation is hard to explain, it’s a bad idea” further the concept of these being general principles to abide by when writing script.

Comments
Post a Comment