Python Tutorial 30 --- "How Import Works In Python?"
Python Tutorial 30 --- "How Import Works In Python?" As always I am again going to repeat: not to name our file similar to a module name. The reason for that, I finally will be sharing with you in this particular tutorial.We are going to name our files file1.py and file2.py. In this tutorial we aim to understand the working of the import statement, so we can have a better grasp of the concept and resolve common importing issues. In Python, we give access to a module by using a keyword import . To use any package in our code, we must make it accessible by importing it first. There are many ways we can import a module in python, but what can be easier than using a single keyword, so it is also the most common way for importing. How does the import keyword work? When we write a certain module name along with the import keyword, it will start searching for a file with that name having an extension .py . After finding the file, it will import it into our program, whic...