An entry point is a conventionally designated function that coordinates a program's execution. In a small Python script, define a controlling function named main and call it. section 11.1
Listing 11.1 File script1.py
def main(): #1
print("this is our first test script file")
main() #2
A minimal entry point defines main first, then invokes it at the bottom of the file. section 11.1
As a script grows, keep the entry point separate from reusable functions such as num2words. Guard the call with if __name__ == '__main__' so the file can also be imported as a module for testing, debugging, or reuse. section 11.3
A script that is also a module
Place reusable functions above the entry-point guard, then call main only when the file runs as a script. This keeps importing from triggering the program's controlling behavior. section 11.3
The same pattern scales to packages: a main function can coordinate functionality supplied by separate cleaning, processing, and exception modules. section 18.6









