From the course: Building Tools with Python

Unlock the full course today

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

Accepting arguments

Accepting arguments - Python Tutorial

From the course: Building Tools with Python

Start my 1-month free trial

Accepting arguments

- [Instructor] Some scripts stand alone and don't need any input to tell them how to operate. Though many tools require some kind of input, whether that's information about what mode to operate in, what feature to use, or what files to work within. And to provide this information for a script, we have a few options. The most basic option is to declare a bunch of variables up at the top of the script, and use those to provide information to the rest of the program. If the program ever only works with very specific files, options, or other values, this can be a good approach. But to make any kind of change, to these variables requires editing the script, and that's not very user friendly. For example, if I built the slide counter app in this way, I'd need to open up the script and save a path to a set of slides or provide a list of file names to the script. And that's a lot of typing. It's prone to errors and it's not something…

Contents