Docstring
Domain: Programming Fundamentals
π― Motivation
A docstring is a special comment right after a function/class definition that documents what it does. Tools can extract them.
π Concrete Example
def add(a, b): '''Return the sum of a and b.''' return a + b - the triple-quoted string is a docstring. help(add) shows it.
π Analogy
A label on a filing cabinet drawer - βTax documents 2023β tells you whatβs inside without opening it. Docstrings tell you what a function does without reading its code.