- Docstrings are the very first items in a module, function, class, or method; if they are put elsewhere, chances are, tools that won't recognize them as docstrings.
- Docstrings can be single or multi-line, as shown in the following, docstring_example.py:
def get_pressure(): """Returns the pressure in the system.""" return sys_press def calc_press_diff(in, out): """Calculates the pressure drop across a valve. :param in: Input pressure :param out: Output pressure :return The valve pressure drop """ deltaP = out - in return deltaP
- By convention, single-line docstrings are for obvious use cases. The reason triple quotes are used, even for one line, is to easily allow for future expansion of the docstring, if needed.
- A single-line ...