4/21/2025 at 9:16:32 AM
It's absolutely baffling that an article called demystifying decorators does not actually describe decorators at all, preferring to keep them a mystery. Decorators are nothing more than a special syntax for calling a function, the meat of which can easily be explained in a single paragraph including a supporting example.by adammarples
4/23/2025 at 4:29:35 PM
It most certainly does.> Congratulations! You wrote your first decorator. Even if it looks different to what you think a decorator should look like—you usually see them used with the @ notation, which we'll discuss in Part 3—store_arguments() is a decorator.
And:
> A decorator is a function that accepts another function as an argument and returns yet another function. The function it returns is a decorated version of the function you pass as an argument. (We'll return to this definition and refine it later in this decorator journey)
I have no idea why you are claiming something that is plainly false based on the text of the article.
by bigstrat2003
4/23/2025 at 1:14:58 PM
More bafflement: is this refering to the programming decorator pattern or something else? I.e. the one everyone learns about when they learn patterns for the first time??No idea why they would be related to closures
by pipes
4/23/2025 at 1:42:06 PM
This is about Python decorators: https://docs.python.org/3/glossary.html#term-decorator. In summary, they are functions that return functions, which allow you to wrap their behaviour (e.g. add a cache, transform a function into an HTTP API handler, etc.)As far as I can tell, they're not related to the design pattern, but I never had to use that.
by maleldil
4/23/2025 at 2:40:34 PM
They implement the design pattern.by F-W-M
4/25/2025 at 5:59:07 AM
It sounds like they do it in a functional style rather than the object orientated one I see a lot.by pipes
4/25/2025 at 5:59:18 AM
Thanksby pipes