Modules are Used to Define Things : Module « Introduction « Python Tutorial






A Simple Module Containing a Function 

# c:\python\hello2.py
def hello():
    print "Hello, world!"

You can then import it like this:

sys.path.append('c:/python')
import hello2
hello2.hello()








1.9.Module
1.9.1.Modules are Programs
1.9.2.To reload the simple module, you would use the following:
1.9.3.Modules are Used to Define Things
1.9.4.A Module with Conditional Test Code
1.9.5.Getting Help with __doc__
1.9.6.Find out the Source