Python does not have a defined entry point like Java, C, C++, etc. Rather it simply executes a source file line-by-line. The if
statement allows you to create a main
function which will be executed if your file is loaded as the "Main" module rather than as a library in another module.
To be clear, this means that the Python interpreter starts at the first line of a file and executes it. Executing lines like class Foobar:
and def foobar()
creates either a class or a function and stores them in memory for later use.