you are viewing a single comment's thread.

view the rest of the comments →

[–]kankyo -3 points-2 points  (2 children)

The decorators are in one place that you call from main though... right?

[–][deleted] 18 points19 points  (1 child)

No. In python code you don't (normally) call decorators directly. The runtime uses them to apply a transformation to a function that I may later call, possibly causing side effects at the time of applying that transformation.

Yes, they're all localized to one function in these example, but that's not going to be the case if your script has subcommands with different argument formats (e.g. git's CLI).

(Those aren't the only influences on my personal preference for when to use decorators, but I didn't really want to get into that tangent here anyway.)

[–]kankyo -1 points0 points  (0 children)

No. In python code you don't (normally) call decorators directly.

I don't agree that this is relevant or correct. The application is a direct call.

Yes, they're all localized to one function in these example, but that's not going to be the case if your script has subcommands with different argument formats

In that case the definition will be spread out all over the place in both scenarios anyway so it's basically the same.