12.7 Summary
In this chapter, we’ve looked at two kinds of decorators: simple decorators with no arguments and parameterized decorators. We’ve seen how decorators involve an indirect composition between functions: the decorator wraps a function (defined inside the decorator) around another function.
Using the functools.wraps()
decorator ensures that our decorators will properly copy attributes from the function being wrapped. This should be a piece of every decorator we write.
In the next chapter, we’ll look at the PyMonad library to express a functional programming concept directly in Python. We don’t require monads generally because Python is an imperative programming language under the hood.