Possible Duplicate:
(可能重复:)
What does if __name__== "__main__"
do?
(if __name__== "__main__"
怎么办?)
I've seen some code samples and tutorials that use
(我见过一些使用的代码示例和教程)
def main():
# my code here
if __name__ == "__main__":
main()
But why?
(但为什么?)
Is there any reason not do define your functions at the top of the file, then just write code under it? (是否有任何理由不在文件顶部定义您的函数,然后只在其下编写代码?)
ie (即)
def my_function()
# my code here
def my_function_two()
# my code here
# some code
# call function
# print(something)
I just wonder if there is any rhyme to the main?
(我只是想知道主要有没有押韵?)
ask by Wizzard translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…