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