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

Virtual Environment
An isolated Python environment that maintains its own set of packages, independent of the system Python installation.
Python Metaclass
A class whose instances are classes themselves โ€” the class of a class that controls how classes are created and behaved.
Slots
A class mechanism that restricts attribute creation and reduces memory usage by using a fixed set of instance variables.
SQLAlchemy
The most popular Python SQL toolkit and ORM that provides a full suite of database abstraction patterns.
Uvicorn
A lightning-fast ASGI server for Python, commonly used to serve FastAPI and other async web applications.
Type Hints
Optional annotations that indicate the expected types of variables, function parameters, and return values.
View All Python Terms โ†’