What is a decorator in Python and how is it applied?

Python Developer Medium

Python Developer — Medium

What is a decorator in Python and how is it applied?

Key points

  • Decorators enhance functionality of functions or classes
  • They are denoted by @ symbol followed by the decorator name
  • Decorators are commonly used for logging, authentication, and caching
  • They help keep code modular and DRY

Ready to go further?

Related questions