IMPORTANT PYTHON STANDARDS - CameronAuler/python-devops GitHub Wiki

Defining The Main Function

When a Python project is run, each file has a dunder(aka. magic) functional called __name__ which is set to the name of the file with the .py extension removed except for the file that is directly passed to the interpreter(The file that you run) which is set to __main__. The code within the if statement is only passed to the interpreter if the module that it is in is passed to the interpreter(run) directly.

if __name__ == "__main__":
    main()

Why You Should Use Python if __name__ == "__main__"