The as a keyword in Python(for creating alias for the module)
Now, we are going to learn about the as a keyword in python. The as keyword is used to create an alias. It is often useful in places, where we cannot use the assignment operator, like in the import statement. Now, Let’s have a look at a simple example, which demonstrates using the as a keyword, to create alias in python programs.
Python AS
As you can see in the above program, we have imported the math module for example, and then we are using them as a keyword, we are creating an alias for the module, which is m. So, in the program, we can make use of the alias to do things related to the module. So, in the print statement, we are printing the value of pi, which can be found now, as m.pi.
So, whenever you wish to have alias for some module, you can simply use the keyword, as we have used it in the above program, to have an alias for the module name. It is very useful, and the as keyword is also used with some other stuff, like with the except block while we are doing exception handling, or while we are using the with keyword, we can use the as keyword there as well. You can try using the as a keyword in other places as well.