You can often see this (variation a):
def main():do_something()do_sth_else()if __name__ == '__main__':main()
And I am now wondering why not this (variation b):
if __name__ == '__main__':do_something()do_sth_else()
Or at least this (variation c):
if __name__ == '__main__':def main():do_something()do_sth_else()main()
Of course the function calls inside main()
might not be function calls, they just represent anything you might want to do in your main()
function.
So why do people prefer variation a over the others? Is it just style/feeling or are there some real reasons? If possible, please also link sources.