From the course: Learning ArcGIS Python Scripting
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Use variables to make scripts flexible - ArcGIS Pro Tutorial
From the course: Learning ArcGIS Python Scripting
Use variables to make scripts flexible
- [Instructor] Variables are used as placeholders in scripts for information not yet known when the script is being written or for values that could change over time. They make the scripts flexible and allow the scripts to get information at runtime. Variables can be used to prompt for input from users, to get input from the properties of projects, maps, and data, and even to extract data from attribute tables and text files. For example, you can write a script that looks at a water wells feature class and selects all the wells where lead has been detected. But you can use a variable as a stand-in for the feature class name and also a variable for the contaminant so that way, when the user runs the script, they can specify which water wells they want to work on and which contaminant they're interested in. The variables act as a placeholder and allow you to write the script without knowing what the user might pick at runtime. Variables can hold text strings, such as the name of a town…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.