๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout 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

Lambda Function
An anonymous, single-expression function defined inline using the lambda keyword.
Pandas
A powerful data analysis and manipulation library providing DataFrames and tools for working with structured data.
Virtual Environment
An isolated Python environment that maintains its own set of packages, independent of the system Python installation.
Python Typing Module
A standard library module providing type hints for function signatures and variables, enabling static analysis without runtime enforcement.
Type Hints
Optional annotations that indicate the expected types of variables, function parameters, and return values.
Python Interpreter
The program that reads and executes Python code, translating it into machine instructions at runtime.
View All Python Terms โ†’