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 - Python Tutorial
From the course: Building Tools with Python
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…
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.
Contents
-
-
-
-
Exploring the sample tool3m 6s
-
(Locked)
Using shell commands from Python3m 43s
-
(Locked)
Challenge: Use shell commands in Python52s
-
(Locked)
Solution: Use shell commands in Python2m 4s
-
(Locked)
Accepting arguments6m 31s
-
(Locked)
Challenge: Practice with arguments55s
-
(Locked)
Solution: Practice with arguments1m 28s
-
(Locked)
Providing error messages and logging5m 29s
-
(Locked)
Ensuring functionality2m 53s
-
(Locked)
Challenge: Check for necessary conditions51s
-
(Locked)
Solution: Check for necessary conditions1m 33s
-
(Locked)
Adding a user interface4m 28s
-
(Locked)
Packaging and distributing a tool4m 14s
-
(Locked)
Supporting the tool2m 2s
-
-