A main function


You could write your code in the main body of your Python file, but using functions and passing arguments to it will make your code easier to maintain and understand. Therefore I recommend that you always write every script with a function called "main".

If you execute this file you might be surprised that nothing happens. This is so because we only defined the function, we never used it. We'll do that next.


examples/basics/hello_world_main.py
def main():
    print("Hello")
    print("World")

This won't run as the main function is declared, but it is never called (invoked).