Loading section...

Docstrings

Basic Docstrings Use triple quotes for docstrings. A simple docstring is a single line that describes what the function does: Multi-line Docstrings For functions with parameters, return values, or complex behavior, use a multi-line docstring that documents the interface completely: This multiline docstring format provides everything a user needs: a summary, detailed description, parameter documentation, return value, exceptions, and usage examples. Docstring Structure A well-structured docstring contains several key components that make it comprehensive and useful. Docstring Best Practices The difference between a helpful docstring and a useless one comes down to specificity and completeness. Write docstrings for any function that will be used by others or that you might return to later. T