I've started on my Python course. So far, the code has been familiar because the first few basic codes are similar to Javascript. And then modules happened. Confusion and despair! What is the world is 'if __name__ == "__main__": ' and why must I reach this section of my course on a public holiday when none of the instructors are in :( Stack overflow to the rescue, providing me a lifeline while I was drowning in a pit of serpents. I feel eternally indebted to a particular Mr Fooz. Picture from here From my understanding, when the Python interpreter reads a source file, it first sets the variable __name__ and then it executes all the code in the file. If that particular file that you are running(i.e. your module) is the main program, the interpreter will assign '__name__ = "__main__" '. Thereafter, any code in the aforementioned 'if' statement is run. If you have, instead, imported a module, the interpreter assigns '__name__