4 ms·
Decorators in Python
by yoloyoloyoloa 5y ago
Decorators in Python
- turndown 5y agoHave 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.)
- yoloyoloyoloa 5y agoWow 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.
- mrfusion 5y agoIt’s just a super fancy way to put a function around an existing function.