Hacker News new | ask | show | jobs
by yoloyoloyoloa 1573 days ago
Decorators in Python
2 comments

Have you ever read the chapter on Decorators from Design Patterns? I’d recommend that for a full treatment, but basically it’s just a way of letting you add on additional work for a function call to do. If we had a decorator called @log(), and a function add_two, if we added this decorator on to add_two it will log the function call or some other aspect(as we define it.)
Wow thanks im gonna read that today! That explanation makes quite a bit of sense. Ive been reading over some code to try understand what it does and now its starting to make more sense.
It’s just a super fancy way to put a function around an existing function.