juniorPython
Python Docstrings
Updated May 4, 2026
Short answer
In-code documentation for modules and functions.
Deep explanation
Strings enclosed in triple quotes that explain purpose and parameters, accessible via the help() function or .__doc__.
Real-world example
Explaining the expected inputs for a public-facing API library.
Common mistakes
- Using docstrings as long-form comments for internal logic instead of documentation.
Follow-up questions
- What is the __doc__ attribute?