In this video, Jennifer Harrison explains how variables are used in Python to make scripts flexible. Learn the rules for naming variables and how variables are populated.
- [Instructor] A variable is a placeholder for a value.…Variables can hold text strings…such as the name of a town or the new name…you want to give a map document.…Variables can just as easily hold numeric values…such as the maximum value you're looking for…for the length of a line.…In object-oriented scripting languages like Python,…variables can also hold objects.…In ArcMap, an object might be a map document,…a feature class, or a goedatabase.…
I'm gonna go over to Idol and demonstrate…some of the points about using variables in Python.…I'll just use the shell window…rather than writing an actual script.…Variables can have almost any name you want,…it's just something you make up.…As long as you follow a few simple rules…and don't use any of the reserved words…in Python, like print.…
I'll make a variable to hold a map document name.…In an actual script, this might be read in…from an existing file, or the script…might prompt the user for the name of this file.…I'll add another variable to hold my initials.…Again, in an actual script, I could prompt the user…
- Writing and running Python scripts in IDLE
- Making scripts flexible with variables
- Commenting scripts
- Manipulating string data
- Object-oriented programming in Python
- Creating loops
- Reading and writing text files
- Capturing input at runtime
- Documenting your scripts
Skill Level Beginner
1. Python for ArcGIS Basics
2. Strings, Numbers, and Variables
Work with numeric values5m 22s
3. Syntax Rules
4. Manipulating Strings
5. Object-Oriented Programming
6. Using Loops
7. Generate Log Files
8. Input at Run Time
9. Help Documents
Documenting a script1m 59s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.