AI engineering glossary · Python core

What is docstring?

Docstring: A string literal placed as the first statement of a module, function or class to document it. Python stores it in the object's __doc__ attribute, and help() and editors display it. Triple quotes are conventional so it can span lines.

Level: intermediateTopic: Python core

Docstring: an example

def area(r): followed by """Return the area of a circle of radius r.""" lets help(area) print that sentence.

Related terms

More Python core terms

Where you learn it

Docstring is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.