3.3.5 Documenting Function Headers

The purpose of a function is to encapsulate a portion of your program. A programmer can call a function without needing to know precisely how it does its job. As a result, documentation that indicates what the function does and how to use it should always immediately follow the function header. Because this function documentation is so important, we use a separate syntax for it: matching sets of three double-quotes (the " character repeated 3 times) enclose the function documentation. It should look like this:

The text in between the three double-quotes is a special kind of comment called a docstring, short for document string. You can only use docstrings when you are defining a function, starting on the line immediately after the function header. The docstring can span multiple lines if need be, as shown in the example above.