
Wade A. answered 05/12/19
Experienced Teacher with Specialties in Computer Science and Math
If you are familiar with Java or C this can be thought of as where the main() method is. The purpose is because python files can be imported into as packages easily. If the file you are working on may be imported but you do not want the code to run then this statement is important.
Simply the if __name__ == "__main()__": is an if statement that checks to see if the name of the program running is main and if so then execute the code, but if false then don't. The only time it is true is when the file the code is in is the main code being executed.
For more details see https://stackoverflow.com/questions/419163/what-does-if-name-main-do