๐ŸŽ 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

Slots
A class mechanism that restricts attribute creation and reduces memory usage by using a fixed set of instance variables.
ABC (Abstract Base Class)
A class that defines a common interface for subclasses by declaring abstract methods that must be implemented.
Python Metaclass
A class whose instances are classes themselves โ€” the class of a class that controls how classes are created and behaved.
Requests Library
An elegant HTTP library for Python that simplifies making web requests with a human-friendly API.
Lambda Function
An anonymous, single-expression function defined inline using the lambda keyword.
Python Descriptors
Objects that define __get__, __set__, or __delete__ methods, controlling how attribute access works on other objects.
View All Python Terms โ†’