Decorators in Python

GeneratorenDatum & Zeit

Decorators are a powerful feature that let you modify or extend the behavior of functions or methods without changing their code.

They are essentially functions that take another function and return a new function – like wrapping a gift with extra features.

Common uses: logging, timing execution, access control, caching, and more.

Functions as First-Class Objects

Python treats functions like any other object – you can pass them around.

Basic Decorator

A decorator is a function that takes a function and returns a wrapped version.

The @ Syntax

The clean way to apply decorators.

Decorators with Parameters

Common Built-in Decorators

  • @staticmethod – method doesn't receive self
  • @classmethod – method receives class
  • @property – method as attribute

Quick Quiz

Wir haben die Materialien überprüft, dennoch können Fehler vorkommen. Der Inhalt dient ausschließlich Bildungszwecken, daher verwende ihn auf eigene Verantwortung und überprüfe ihn bei Bedarf mit anderen Quellen.

✨ Frag Lara — deine KI-Lernpartnerin

Entsperre personalisierte Lernunterstützung. Lara kann Lektionen erklären, Themen zusammenfassen und deine Lernfragen beantworten — verfügbar ab dem Go-Tarif.


Lara hilft dir, schneller zu lernen — exklusiv für ReadyTools Go-, Plus- und Max-Mitglieder.

Verfolge deinen Fortschritt 🚀

Lerne einfacher, indem du deinen Fortschritt kostenlos verfolgst.