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

Pydantic
A data validation library that uses Python type annotations to validate and serialize data with automatic error reporting.
Python Context Variable
A variable that maintains separate values for each execution context, enabling implicit state passing in async code without global variables.
Python Property
A built-in decorator that lets you define methods that behave like attributes, enabling controlled access to instance data.
Python Profiling
Measuring where Python code spends time and memory to identify performance bottlenecks and optimization opportunities.
Docstring
A string literal placed as the first statement in a module, class, or function to document its purpose and usage.
NumPy
A fundamental library for numerical computing in Python, providing efficient multi-dimensional arrays and mathematical operations.
View All Python Terms โ†’