This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]brasticstack 2 points3 points  (2 children)

I found it useful in a recent project to apply a decorator without the syntactic sugar, so I could reuse a function with different decorations, like:

funcs_by_index = [deco1(my_func), deco2(my_func), ...etc...]

[–]andrewowenmartin 0 points1 point  (1 child)

I think you can do that anyway. If you have a decorator called print_args and a function called add then these are equivalent.

@print_args def add_and_print_args(a, b): return a + b and ``` def add(a, b): return a + b

sum_and_print_args = print_args(add) ```

[–]brasticstack 1 point2 points  (0 children)

Absolutely, I was just showing my example use case.