Another detailed explanation of Python decorators¶
There are a ton of guides on decorators out there and ebooks that go into great depth. Just google it for a huge listing of results, or skip to the what seems to be the canonical reference on the topic.
I've read a lot of these over the years, but I recently read a newer article that had a good tidbit on closures and how these work in Python:
In Python, a closure provides full read access to any variable in the function's scope chain, but only provides write access to mutable objects (lists, dictionaries, etc.).
Remember, decorators can be a useful way to extend a method or functions use without modifying the function directly. In fact, I've written about decorators and some common uses a few times: