Python From Keyword

The from keyword in Python

Now, we are going to learn about the keyword, which is very useful in our programs. Basically, when we are required, to import only the specified section from a module, we can make use of the from keyword. Let’s consider an example so that we can get a clearer picture of what the from keyword does.

Python From Keyword

Let’s say that we want to import only the ceil method from the math module, in such a situation, we can make use of the from a keyword, and import only the required things from the math module. Let’s have a look at a simple example, which demonstrates the same thing.

As you can see in the above program, we have used the form a keyword, to import only the ceil method from the math class. So, this is often useful when we need to import only some specific section from some module. So, as and when required, we can make use of the from keyword in our programs, wherever we need to import only some section from the module. In order to have multiple sections imported from the keyword, we can simply separate them using the comma.