Jun-03-2018, 08:09 PM
People use __name__ to determine if the script is being imported or not. If it's equal to "__main__" then it's not an import. The idea being, you want to run your main method if and only if you're not being imported.
Java knows to call your main method. Python has no such similarity. When you run or import a script, the contents are executed. So it's up to the script to determine whether it should run its main function or not, rather than being built into the language.
Java knows to call your main method. Python has no such similarity. When you run or import a script, the contents are executed. So it's up to the script to determine whether it should run its main function or not, rather than being built into the language.