🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Python Beginner

What is Docstring?

A string literal placed as the first statement in a module, class, or function to document its purpose and usage.

Docstrings use triple quotes and describe what code does, its parameters, return values, and examples. They are accessible at runtime via __doc__ attribute and used by help() function, IDE tooltips, and documentation generators.

Common formats include Google style, NumPy style, and reStructuredText (Sphinx). Tools like Sphinx generate beautiful HTML documentation from docstrings. PEP 257 defines docstring conventions.

Related Terms

Python Context Variable
A variable that maintains separate values for each execution context, enabling implicit state passing in async code without global variables.
Python Iterator Protocol
The interface requiring __iter__() and __next__() methods, enabling objects to be used in for loops and other iteration contexts.
PIP
The standard package installer for Python, used to install and manage third-party libraries from PyPI.
GIL (Global Interpreter Lock)
A mutex in CPython that allows only one thread to execute Python bytecode at a time, limiting true parallelism.
Python Typing Module
A standard library module providing type hints for function signatures and variables, enabling static analysis without runtime enforcement.
Pandas
A powerful data analysis and manipulation library providing DataFrames and tools for working with structured data.
View All Python Terms →