Python Decorators A decorator receives a function or class and returns a replacement, often a wrapper that adds behavior such as logging, authorization, caching, or registration.