Python Module

for more updates visit:

VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR & SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR

PYTHON MODULE

Group of functions, classes, variables

for more updates visit:

What is Python Module

A Module is a file containing Python definitions (docstrings) , functions, variables, classes and statements.

Act of partitioning a program into individual components(modules) is called modularity. A module is a separate unit in itself.

It reduces its complexity to some degree It creates numbers of well-defined, documented boundaries

within program. Its contents can be reused in other program, without having

to rewrite or recreate them.

VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR & SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR

for more updates visit:

Structure of Python module

A python module is simply a normal python file(.py) and contains functions, constants and other elements.

Python module may contains following objects:

docstring

Variables and constants Classes Objects Statements Functions

Triple quoted comments. Useful for documentation purpose For storing values

To create blueprint of any object Object is an instance of class. It represent class in real world Instruction Group of statements

VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR & SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR

for more updates visit:

Composition/Structure of python module

MODULES VARIABLES

FUNCTIONS VARIABLES

CLASSES MEMBERS METHODS

VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR & SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR

OTHER PYTHON MODULES

IMPORT

OTHER PYTHON MODULES

for more updates visit:

Importing Python modules

To import entire module

import Example: import math

To import specific function/object from module:

from import Example: from math import sqrt

import * : can be used to import all names from module into current calling module

VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR & SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download