May 16, 2013

Python Modules and Packages

python module
- module __name__
- a module can contain executable statements as well as functional statements
- those are executed only once
- modules has its private symbol table
- modules can import other modules
- if you include __name__ == __main__ -> then, it will execute
- otherwise, module can be imported too

python module search path
- module is first searched into module path
- then, module is searched in sys.path
- sys.path same as PATH variable in shell


what is python compiled file
- byte compiled.
- modification time

python standard modules
- python comes up with standard modules
- that is called python library reference
- dependant of system implementation

python packages:
- module namespace - by using dotted module names i.e. A.B
- import * = must be in __init__.py file  :