▲ | dijksterhuis 2 days ago | |
the thing that bothered me most reading through it was using decorators to mutate some global state with the `data` list variable. like… it… just… it felt wrong reading that in the examples. felt very `def func(kw=[])` adjacent. i can see some rare uses for it, but eh. i dunno. (also didn’t find the closure stuff that insightful, ended up skipping past that, but then i know decorators, so… maybe useful for someone else. i dunno.). | ||
▲ | t-writescode 2 days ago | parent [-] | |
My "proudest" use of decorators has been in adding metrics gathering for functions in python, so you'd get automated statsd (and later prometheus) metrics just by having @tracked (or whatever I had its name be - it's been like 7 years) on the function header. In a sense, that was mutating a global variable by including and tracking the metrics gathering. I imagine this person's early professional exposures to it and need to create their own also came from a similar situation, so "mutating global state" and closures sorta clicked for them. People learn things by coming to those things from many different entry points and for many different reasons. This is another one of those instances :) |