Many Pythonistas are familiar with using decorators, but far fewer understand what’s happening under the hood and can write their own. It takes a little effort to learn their subtleties but, once grasped, they’re a great tool for writing concise, elegant Python.
This post will briefly introduce the concept, start with a basic decorator implementation, then walk through a few more involved examples one by one.
What is a decorator
Decorators are most commonly used with the @decorator
syntax. You may have seen Python that looks something like these examples.
To understand what a decorator does, we first have to …read more
Continue reading Make Your Python Prettier With Decorators→