May-15-2017, 05:02 PM
(May-15-2017, 03:15 AM)Skaperen Wrote: what can these be used for?They are syntax for wrapping a function definition at definition time. They're not for changing built-in / third party functions at runtime. They're logically equivalent to other forms of wrapping. The best example I've seen is caching / memoization, and it doesn't necessary make the code shorter, though it helps with separation of concerns and if the decorator is reusable then you can have less code.