June 2017
Beginner
352 pages
8h 39m
English
Exceptions are an important aspect of the API of a function. Callers of a function need to know which exceptions to expect under various conditions so that they can ensure appropriate exception handlers are in place. We'll use square-root finding as an example, using a home-grown square-root function, courtesy of Heron of Alexandria (although he probably didn't use Python).
Callers of a function need to know which exceptions to expect:

Place the following code in a file roots.py:
def sqrt(x): """Compute square roots using the method of Heron of Alexandria. Args: ...
Read now
Unlock full access