Module
Module is a file that contains definitions of functions and classes
'''
	Module m1
'''
#!/usr/bin/python

def f_1():
    '''
        Function f_1 in module m1
    '''
    print("f_1  ...")

def f_2():
    '''
        Function f_2 in module m1
    '''
    print("f_2 ...")

def main():
    f_1()
    f_2()

if __name__ == "__main__":
    main()
		
Import Module
'''Import a whole module'''

import m1
----------------------
m1.f_1()
m1.f_2()
m1.main()
'''Import the functions in a module'''

from m1 import *
----------------------
f_1()
f_2()
main()
'''Import a specific function from a module'''

from m1 import main
-----------------------
main()
Module Search Path
  • The current directory
  • PYTHONPATH
  • Installation-dependent default
  • Reference
  • Python Tutorial