4 ms·
If `apply` is your own code, you could refactor it to @apply(lst) def naming_is_hard(): ... I came to python after working in JS fulltime for years,
by rjmill 4y ago
If `apply` is your own code, you could refactor it to
@apply(lst)
def naming_is_hard():
...
I came to python after working in JS fulltime for years, and used to complain about the exact same thing. After I started using decorators, I stopped complaining about the single-line lambdas.
For any non-python devs looking at my example, it's equivalent to
def naming_is_hard():
...
naming_is_hard = apply(lst)(naming_is_hard)
It's a nice way to pass functions into other functions, much like how you'd do with a lambda.
edit: s/list/lst/g because autocorrect "fixed" the variable name.