docstring

A string literal placed as the first statement of a module, function or class, which Python keeps as its documentation.

In more detail

Docstrings are usually triple-quoted so they can span lines. help() and tools such as IDEs show them, which makes them the note the code itself cannot give: what a function is for, its arguments and what it returns. A comment is ignored; a docstring is kept.

Examples

def area(r):
    """Return the area of a circle of radius r."""
def total(lines):
    """Total of (price in pence, count) lines."""

Related terms

Taught in

References