if __name__ == "__main__":
main()
which means run the function main if this module is
explicitly invoked by the user
note that it is not run if this module was imported
Example times module
#!/usr/bin/python
import sys
def multiplyby10(value):
return value+’0’
if __name__ == "__main__":
if len(sys.argv) == 2:
print ’testing the times module’
print multiplyby10(sys.argv[1])
the above code needs to be saved in file times.py
没有评论:
发表评论