4 ms·
So you're saying: def baz(): bar1() foo() bar2() is hugely better than: @bar def baz(): foo() I think it massively depends on nami
by andybak 11y ago
So you're saying:
def baz():
bar1()
foo()
bar2()
is hugely better than:
@bar
def baz():
foo()
I think it massively depends on naming and the general context. I can see myself choosing either depending on the precise situation.
As with all things in Python (and coding in general) taste and discretion are key: use decorators when they improve legibility and stop using them when they don't.
- tsmarsh 11y agoI think they're saying: def calling_context: bar(foo) is cleaner. The problem with decorators is that they don't know the calling context, or provide a mechanism to adapt to that context short of monkey patching. That said, they are really, really convenient.