๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Python Advanced

What is Python Descriptors?

Objects that define __get__, __set__, or __delete__ methods, controlling how attribute access works on other objects.

Descriptors are the mechanism behind properties, class methods, static methods, and slots in Python. When an object defines __get__(), __set__(), or __delete__(), it becomes a descriptor. Data descriptors (with __set__ or __delete__) take precedence over instance dictionaries, while non-data descriptors (only __get__) defer to instance attributes. This protocol powers Django ORM fields, SQLAlchemy columns, and validation frameworks. Understanding descriptors reveals how Python's attribute access truly works - when you access obj.attr, Python calls type(obj).__dict__['attr'].__get__(obj, type(obj)) if attr is a descriptor.

Related Terms

Python Package
A directory containing Python modules and an __init__.py file, providing a way to organize and distribute reusable code.
Uvicorn
A lightning-fast ASGI server for Python, commonly used to serve FastAPI and other async web applications.
Pydantic
A data validation library that uses Python type annotations to validate and serialize data with automatic error reporting.
Python Coroutine
A function defined with async def that can be paused and resumed, enabling concurrent execution without threads.
Virtual Environment
An isolated Python environment that maintains its own set of packages, independent of the system Python installation.
List Comprehension
A concise syntax for creating new lists by applying an expression to each item in an existing iterable.
View All Python Terms โ†’