Re:Ask HN: What concepts have you never truly understood?
by yoloyoloyoloa on Sunday March 06, 2022 @07:55PM
(#30582879)
Decorators in Python
[ Parent
| on HN ]
Re:Ask HN: What concepts have you never truly understood?
by turndown on Sunday March 06, 2022 @08:48PM
(#30583304)
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.)
Re:Ask HN: What concepts have you never truly understood?
by yoloyoloyoloa on Monday March 07, 2022 @12:07AM
(#30584423)
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.