3.9 Writing testable scripts with the script-library switch
It’s often very easy to create a Python script file. When we provide a script file to Python, it runs immediately. In some cases, there are no function or class definitions; the script file is the sequence of Python statements.
These script files are very difficult to test. Additionally, they’re also difficult to reuse. When we want to build larger and more sophisticated applications from a collection of script files, we’re often forced to re-engineer a script into one or more functions.
3.9.1 Getting ready
Let’s say that we have a handy implementation of the haversine distance function called haversine(), and it’s in a file named recipe_11.py.
The file contains the functions and definitions shown in the Picking an order for parameters based on partial functions in this chapter. This includes a partial function, nm_haversine(), to compute...