The Import Statement
- brings code from the module to a program
- any code in the mdule is executed
- Function and class definitions aren’t executed, but are defined
- has options that affect how objects are referred to
Namespace
- Importing also places modules in the global namespace
- module name
- reference to module contents
- Objects in namespace referring to using dot notation:
module.object
Object and module can be access using the dot notation, where we have the module name, the dot and then the object name.
Import Module
Syntax
import module
Import Alias
import module as alias
- useful for long cumbersome module names
From Import
- import specific objects into namespace
from module import objname
From Import Alias
from module import objname as alias
Multiple From Import
from module import obj1, obj2,..