Skip to content

Python Tips and Tricks

Workshop taught for the Minnesota GIS/LIS Consortium describing some intermediate Python patterns people can use to make their code more readable, maintainable, and performant.

See project

Explore repository

My co-presenter Grace Doherty and I both had similar experiences learning Python as geospatial professionals. We learned enough to get our projects done, but being self-taught meant that there were gaps in our fundamental knowledge of Python. Both of us learned more over time, but we were embarrassed about some of the terrible code we had written earlier in our careers. We wrote this workshop to be the one we wish we had attended years ago.

This workshop focuses on a few specific patterns that we think are good for geospatial professionals:

  • Unpacking
  • Using try/except
  • More extensive use of Python built ins and standard library
  • Context managers
  • Using more tuples and sets instead of lists
  • Iterators
  • Generators
  • Code profiling