The statement added to the final module, allows the module that can be import others, and can be run directly.
fibo.py file:
def fibo():
pass # fibo函数的内容
if __name__=="__main__":
import sys
fib(int(sys.arv[1]))
Then you can run the command line:
python fibo.py 50
The result is:
0112358132134
But when run another script:
import fibo
When the final statement will not be executed.
It can often be used for measurement.