Python Module

« Previous Tutorial Next Tutorial »

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.

Python Module Example

Here is an example program, demonstrating the python module. This program defines a function named printit() and saved in, to use the function printit() from this module on importing it later. Let's look at this python program. This file is saved as

# Python Module - Example Program

def printit(arg):
    print("Hello, ", arg);

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 This file is saved as

# Python Module - Example Program

import mymodule


Here is the sample output produced by the above python program (

python module

« Previous Tutorial Next Tutorial »


Quick Links
Signup - Login - Give Online Test