Decorators are a syntactic feature available in Python that can serve as a convenient and concise tool for modifying, analyzing, or associating functions and methods at the point at which they are defined. Decorators allow programmers to leverage an additional form of modularity and composability within their solutions, helping them add or modify features and functionalities in a relatively quick, concise, and elegant way.
This article covers some background on higher-order functions that is necessary to understand how decorators work, presents an overview of how decorators are defined and used, and illustrates their utility via a few use cases.