Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences 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 refer to our video player troubleshooting guide for assistance.

Listing All Python Keywords

00:00 In this lesson, I will show you how you can list the Python keywords programmatically.

00:07 When you’re in your Python interpreter, you can import the keyword module. That’s a module that’s built in with Python, so you don’t have to pip install it or do some other fancy stuff. It’s just there for you. And once you have imported the keyword module, you can type keyword.kwlist, and then all Python keywords are listed for you. Well, when I’m saying all keywords, that’s not entirely true because in version 3.10, Python introduced soft keywords, and you can list them with keyword.softkwlist.

00:50 These three soft keywords you will meet later again. I will explain them for you as well, like the other keywords, but just take note that there is a small differentiation between normal keywords, or so-called normal keywords, and soft keywords.

01:08 Before we wrap this up, there is another way of listing all the keywords, and that’s using the help() function. So if you type help() and "keywords", then Python lists all the keywords for you.

01:21 Speaking of the help() function, you can also investigate keywords in particular by passing them in—for example, the pass keyword—and there you will get an explanation of the keyword.

01:33 So that’s very handy if you want to find out more about one particular keyword.

01:41 Here is an overview of all the keywords again for you. You can pause this video and have a look at them, but you will meet all of them during this course.

01:51 So now we have looked at the keywords in general. You have a list of them. But what exactly are the keywords? So this you will learn in the next lesson.

Become a Member to join the conversation.