Module provides you to logically organize your python code. The code becomes easier to understand and use after grouping the related code into a module in python.
Here is an example program, demonstrating the python module. This program defines a function named printit() and saved in mymodule.py, to use the function printit() from this module on importing it later. Let's look at this python program. This file is saved as mymodule.py
# Python Module - Example Program def printit(arg): print("Hello, ", arg); return
You can use any python source file as a module just by using the import statement in some other python source file. Here is an example importing the above the mymodule.py. This file is saved as 1.py
# Python Module - Example Program import mymodule mymodule.printit("Devraj");
Here is the sample output produced by the above python program (1.py):