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

Python Package
A directory containing Python modules and an __init__.py file, providing a way to organize and distribute reusable code.
Asyncio
A Python library for writing concurrent code using async/await syntax for non-blocking I/O operations.
Django
A high-level web framework that follows the batteries-included philosophy, providing ORM, admin, auth, and more out of the box.
Scikit-learn
The most popular Python machine learning library providing simple and efficient tools for data analysis and modeling.
Slots
A class mechanism that restricts attribute creation and reduces memory usage by using a fixed set of instance variables.
Type Hints
Optional annotations that indicate the expected types of variables, function parameters, and return values.
View All Python Terms โ†’