In this video, Jennifer Harrison explains the importance of commenting when writing Python scripts. Learn how to properly document a Python script with pseudocode to increase readability.
- [Narrator] It's a really good idea…to put some notes into a script to remind the author,…and others, what the script is all about.…These notes are added as comments.…Comments are completely ignored by the Python compiler.…Comments start with a hashtag;…anything after the hashtag all the way…to the end of the line, is ignored.…You can put a space after the hashtag if you want,…it's not required.…
It's standard practice to put a comment block…at the top of each script that explains…everything the script is gonna do.…It also explains what inputs are required by the script,…who created the script, the date it was created,…and even what sort of outputs to expect from the script.…Comment blocks are usually surrounded by lines of hashtags,…So it'll often look something like this,…just a whole bunch of these on a line.…
And then you put your comments in there,…like the name of the script,…as well as some information…about the inputs and outputs required.…Those angled brackets, the less than…and greater than signs are not required.…
- 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.