Keyword Module in Python Last Updated : 27 Feb, 2020 Comments Improve Suggest changes Like Article Like Report Python provides an in-built module keyword that allows you to know about the reserved keywords of python. The keyword module allows you the functionality to know about the reserved words or keywords of Python and to check whether the value of a variable is a reserved word or not. In case you are unaware of all the keywords of Python you can use this module to retrieve this information. Also, it helps you to check whether a word is a keyword or not just by using its functions on Python shell mode. The functions of this module are: keyword.iskeyword(parameter) This function returns True if the parameter passed is a Python keyword else returns False. The parameter can be a string or a variable storing a string. It accordingly compares the parameter with Python keywords defined in the language and returns the output. Example: Python # Program to check whether a given # word is a Python keyword or not import keyword s ="if" t ="in" u ="GeeksforGeeks" # using iskeyword() function to check print(s, "is a keyword in Python:", keyword.iskeyword(s)) print("lambda is a keyword in Python:", keyword.iskeyword("lambda")) print("print is a keyword in Python:", keyword.iskeyword("print")) print(t, "is a keyword in Python:", keyword.iskeyword(t)) print(u, "is a keyword in Python:", keyword.iskeyword(u)) Output: if is a keyword in Python: True lambda is a keyword in Python: True print is a keyword in Python: False in is a keyword in Python: True GeeksforGeeks is a keyword in Python: False As you can see from the above example that the value of variable s and t is a keyword in Python, thus the function returns True. Similarly, the string GeeksforGeeks is not a keyword, thus the function returns False. keyword.kwlist This is a predefined variable of keyword module that stores all the keywords of Python. Thus it can be used to display all the keywords of Python just by calling it. Example: Python # Program to display the list of Python keywords # importing keyword module import keyword # using keyword.kwlist to display the list of keywords print(keyword.kwlist) Output: ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield'] Note: keyword.kwlist is not a function, hence no parenthesis are used with it. kwlist is a variable defined previously in the keyword module. Comment More infoAdvertise with us Next Article Keyword Module in Python N newtocoding Follow Improve Article Tags : Python python-modules Practice Tags : python Similar Reads Python Module Index Python has a vast ecosystem of modules and packages. These modules enable developers to perform a wide range of tasks without taking the headache of creating a custom module for them to perform a particular task. Whether we have to perform data analysis, set up a web server, or automate tasks, there 4 min read Python Fire Module Python Fire is a library to create CLI applications. It can automatically generate command line Interfaces from any object in python. It is not limited to this, it is a good tool for debugging and development purposes. With the help of Fire, you can turn existing code into CLI. In this article, we w 3 min read Inspect Module in Python The inspect module in Python is useful for examining objects in your code. Since Python is an object-oriented language, this module helps inspect modules, functions and other objects to better understand their structure. It also allows for detailed analysis of function calls and tracebacks, making d 4 min read as Keyword - Python as keyword in Python plays a important role in simplifying code, making it more readable and avoiding potential naming conflicts. It is mainly used to create aliases for modules, exceptions and file operations. This powerful feature reduces verbosity, helps in naming clarity and can be essential whe 3 min read Import module in Python In Python, modules allow us to organize code into reusable files, making it easy to import and use functions, classes, and variables from other scripts. Importing a module in Python is similar to using #include in C/C++, providing access to pre-written code and built-in libraries. Pythonâs import st 3 min read Python Keywords Keywords in Python are reserved words that have special meanings and serve specific purposes in the language syntax. Python keywords cannot be used as the names of variables, functions, and classes or any other identifier. Getting List of all Python keywordsWe can also get all the keyword names usin 11 min read Keywords in Python | Set 2 Python Keywords - Introduction Keywords in Python | Set 1 More keywords:16. try : This keyword is used for exception handling, used to catch the errors in the code using the keyword except. Code in "try" block is checked, if there is any type of error, except block is executed. 17. except : As expl 4 min read Python def Keyword Python def keyword is used to define a function, it is placed before a function name that is provided by the user to create a user-defined function. In Python, a function is a logical unit of code containing a sequence of statements indented under a name given using the âdefâ keyword. In Python def 6 min read Python "from" Keyword The from keyword in Python is mainly used for importing specific parts of a module rather than the entire module. It helps in making the code cleaner and more efficient by allowing us to access only the required functions, classes, or variables.Here's an example.Python# Importing only sqrt function 2 min read Like