🎁 New User? Get 20% off your first purchase with code NEWUSER20 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

Magic Methods
Special double-underscore methods that define how Python objects behave with built-in operations and functions.
Slots
A class mechanism that restricts attribute creation and reduces memory usage by using a fixed set of instance variables.
Virtual Environment
An isolated Python environment that maintains its own set of packages, independent of the system Python installation.
Matplotlib
A comprehensive plotting library for creating static, animated, and interactive visualizations in Python.
Exception Handling
A mechanism for managing runtime errors using try, except, else, and finally blocks to prevent program crashes.
Python Metaclass
A class whose instances are classes themselves — the class of a class that controls how classes are created and behaved.
View All Python Terms →