Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

External Library Options for CLIs

Here are resources for more information about external libraries options:

00:00 Along with the standard library, there are a variety of external libraries that are available to help you build command line interfaces. In this lesson, I’ll tell you a little bit about a few of those.

00:13 Here are some examples of external libraries for command line interfaces. I’m going to give a demonstration in my own code of the click module and also the Python Prompt Toolkit, but all of these are really incredible and useful libraries for command line interfaces. click, I would say, is the most powerful of the bunch. It’s known for being really modular and has a decorator-based syntax.

00:38 This is used by some really large and influential open-source Python projects like Flask and Black. Some other options are docopt, which is great if you like to simply write out a detailed spec which will generate the whole command line interface for you, and then there’s also clize, which I personally really enjoy because it’s super simple to use. You just write out some docstrings underneath the function, and that generates the command line interface for you. Python Prompt Toolkit is a little bit more of an alternative to a traditional command line interface because it has aspects of a graphical user interface as well, so that’s a pretty cool way to start thinking about some of the ways that a command line interface can kind of expand out of just the pure plain text version that I’ve shown you so far.

01:26 An important thing to remember for all of these external libraries is that you’ll have to install them in some way before you can use them. In most cases, that will be as simple as using pip in your terminal and writing something like pip install click, or pip install clize, but in rare cases it might turn out to be a little bit more complicated.

01:47 If you have any trouble, feel free to browse some documentation on these libraries’ webpages for a little more information on how to resolve those troubleshooting issues.

01:56 So, let’s take a look at click and Python Prompt Toolkit in some Real Python code.

Become a Member to join the conversation.