Now you know what a command line interface is and how you can create one in Python by using the Python
In this video course, you’ve learned:
- What the Python
argparselibrary is, and why it’s important to use it if you need to write command line scripts in Python
- How to use the Python
argparselibrary to quickly create a simple CLI in Python
- What the advanced usage of the Python
Writing a good command line interface is a good way to create self-explanatory programs and give users a means of interacting with your application.
If you still have questions, don’t hesitate to reach out in the comment section below and take a look at the official documentation and the how-to guide.
For alternatives to
argparse, check out:
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
dana on Sept. 8, 2022
I was disappointed to find that this course did not cover some of the basic formats for parameters such as:
parser.addargument("-t", "--text", help="The text data to encode into the image, this only should be specified for encoding")
showing you can use multiple formats for the keyword arguments or that the above code will produce a help item like:
-t TEXT, --text TEXT The text data to encode into the image, this only should be specified for encoding
automatically filling in the arg name in CAPS.
I don’t think this is intuitively obvious to the naive student of the course who has never used ‘argparse’.