A Module with Conditional Test Code : Module « Introduction « Python Tutorial






# c:\python\hello.py
def hello():
    print "Hello, world!"
def test():
    hello()
if __name__ == '__main__': test()


# main.py
sys.path.append('c:/python')
import hello

hello.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