In Python, the if __name__ == “__main__” idiom is a guard statement that is used to determine whether the code in the block following it is being run as the main program or being imported as a module into another program.
When a Python script is run, the interpreter assigns the special variable __name__ the value “__main__”.