Sample Chapter 1: Fundamentals of the Python Language

by | Jul 12, 2023

The following is a sneak peek at the first part of a sample chapter from our newest book: Programming ArcGIS Pro with Python: 3rd Edition. This book has been updated for ArcGIS Pro 3.x, and will teach you how to automate your ArcGIS Pro 3.x geoprocessing tasks using Python.

To download a PDF of the full sample chapter, or to see how you can purchase the digital book and exercise data, click the buttons at the bottom of this post.


Python supports many of the programming constructs found in other languages. In this chapter, we’ll cover many of the basic language features found in Python. Initially, we’ll delve into language features, such as adding comments to your code, importing modules, creating and assigning data to variables, and using the built-in primitive data types such as strings and numbers.

Next, we’ll look at the more complex data types that Python offers, such as lists, tuples, and dictionaries. Classes and objects are a fundamental concept in object-oriented programming and in the Python language. We’ll introduce you to these complex data structures, which you’ll use extensively when you write geoprocessing scripts with ArcGIS Pro.

In addition to this, we’ll cover statements, including decision support and looping structures to make decisions in your code, and/or looping through a code block multiple times along with the with statement.

You have many choices for the environment that will be used to write, test, and debug your Python code. In this book we’ll use several environments so that you can become familiar with various options. In this chapter you’ll be introduced to ArcGIS Pro Notebooks, first released with ArcGIS Pro 2.5, which provides a Jupyter Notebook implementation for writing and executing Python code directly in ArcGIS Pro. Future chapters will use IDLE, and the ArcGIS Pro Python Window.

In this chapter we will cover the following:

  • ArcGIS notebooks
  • Commenting code
  • Importing modules
  • Creating variables
  • Using Built-in data types (strings, numbers, lists, dictionaries)
  • Manipulating strings
  • Using classes and objects
  • Decision support statements
  • Looping structures
  • Handling errors with try/except
  • Using functions

Introduction to ArcGIS Pro Notebooks

ArcGIS Notebooks, built on top of Jupyter Notebooks, is an open-source application for creating and sharing documents that contain live Python code, data visualizations, perform analysis, and add narrative text. Notebooks are an excellent way of presenting a story about your data. They are built directly into ArcGIS Pro.

Exercise 1: Introduction to ArcGIS Pro Notebooks

Getting Ready

All Python functionality included with ArcGIS Pro can be accessed from ArcGIS Notebooks including the core Python library, the standard Python library, arcpy, the ArcGIS API for Python, third party packages including NumPy and pandas, and can be extended by installing additional packages through the ArcGIS Pro Python Package Manager.

How to do it…

New ArcGIS Notebooks can be created by going to the Analysis tab and then selecting Python | Python Notebook. That will display the ArcGIS Notebook in a new view window where you can then begin to add code. You can also create a new notebook by going to the Insert tab and selecting New Notebook. After a notebook has been created, you can begin writing code in the cells.

  1. Start ArcGIS Pro and on the startup screen, under Open select Open another project, navigate to the ProgrammingPro/Chapter1/Ex1 folder and open Ex1.aprx file….

For the full details and how to purchase the digital book and exercise data, click the first button below. For a full PDF download of Chapter 1, click the second button below.


Recent Posts

Eric Pimpler
Eric is the founder and owner of GeoSpatial Training Services ( and has over 25 years of experience implementing and teaching GIS solutions using ESRI, Google Earth/Maps, Open Source technology. Currently Eric focuses on ArcGIS scripting with Python, and the development of custom ArcGIS Server web and mobile applications using JavaScript. Eric is the author of Programming ArcGIS with Python Cookbook - 1st and 2nd Edition, Building Web and Mobile ArcGIS Server Applications with JavaScript, Spatial Analytics with ArcGIS, and ArcGIS Blueprints. Eric has a Bachelor’s degree in Geography from Texas A&M University and a Master's of Applied Geography degree with a concentration in GIS from Texas State University.

Sign up for our weekly newsletter
to receive content like this in your email box.