Flexible decorators

Flexible decorators#

This short section covers a niche pattern that is used by some decorators, like functools.lru_cache from the standard library. This is an optional section that is included here for the sake of completeness.

Skipping this section is very reasonable if this is the first time you are going through these materials.

Objectives#

The objective of this section is to show you how to create flexible decorators that can be used with and without arguments.

Pre-requisites#

For this section, it’s assumed you know how to work with, and implement, decorators that accept arguments.