Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 5
    Does this answer your question? python decorator TypeError missing 1 required positional argument Commented Jan 8, 2021 at 9:55
  • 1
    Bare @timer returns decorator function. On the other hand, @timer() will execute timer first then return decorator which in turn used to decorate decorated. Commented Jan 8, 2021 at 9:58
  • @EricLeung It doesn't explain what is happening, and take for example functools.lru_cache, it works as well as many other decorators without explicit calls () Commented Jan 8, 2021 at 10:00
  • @bullseye it explains the reason if you read carefully. lru_cache is probably not a parametrizable decorator (however, I did not check), but your timer decorator is parametrizable, this is the key point. Commented Jan 8, 2021 at 10:04
  • 1
    @Tryph stackoverflow.com/q/653368/476 Commented Jan 8, 2021 at 10:35