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

Categories

Python Intermediate

What is Decorator?

A function that modifies or extends the behavior of another function or class without changing its source code.

Decorators use the @decorator_name syntax placed above a function definition. They take a function as input and return a modified version. Common uses include logging, authentication checks, caching, and timing execution.

Built-in decorators include @property, @staticmethod, and @classmethod. Popular third-party decorators include @app.route (Flask) and @login_required (Django).

Related Terms

Exception Handling
A mechanism for managing runtime errors using try, except, else, and finally blocks to prevent program crashes.
Class
A blueprint for creating objects that bundles data (attributes) and behavior (methods) together.
Python Iterator Protocol
The interface requiring __iter__() and __next__() methods, enabling objects to be used in for loops and other iteration contexts.
Python Metaclass
A class whose instances are classes themselves โ€” the class of a class that controls how classes are created and behaved.
Uvicorn
A lightning-fast ASGI server for Python, commonly used to serve FastAPI and other async web applications.
FastAPI
A modern, high-performance Python web framework for building APIs with automatic OpenAPI documentation and type validation.
View All Python Terms โ†’