From the course: Learning ArcGIS Python Scripting (2018)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Command-line arguments

Command-line arguments - ArcGIS Tutorial

From the course: Learning ArcGIS Python Scripting (2018)

Start my 1-month free trial

Command-line arguments

- [Instructor] ArcPy's sys module allows scripts to accept command line arguments, also called parameters. Let's see how to write a script that accepts and makes use of parameters. Since this is just little demo script to show how command line arguments work, I'm gonna skip all the niceties of a comment block and sudo code. To use the Python sys way of grabbing the parameters, the sys module has to be imported. Once the script has access to the sys module, the argv list is available. So the first thing I'll do is to import the sys module in my script. Now I have access to the argv list. I can just use it. I'll print the first argument you entered is sys.argv sub one. And then I'll print the second argument you entered, the sys.argv sub two. By the way, there is a zero element in this list, sys.argv sub zero, but it's always the name of the script that's being run. So I'll save this script. Now the problem is this script can't be run in IDLE because there's no way to enter command line…

Contents