News for hackers. Stuff that matters.
Re:Python decorators they don't tell you about by kissgyorgy on Sunday January 07, 2018 @08:09AM (#16090743)
No, if you read the article, you can learn that a decorator is a callable which can return ANYTHING, not just callables.
Re:Python decorators they don't tell you about by abhirag on Sunday January 07, 2018 @11:28AM (#16091364)
Thanks, I stand corrected :) That makes me wonder , I have not been able to imagine a usecase for it when it doesn't return a callable, the article doesn't help in that regard either. Got some thinking to do I guess.
Re:Python decorators they don't tell you about by Walkman on Sunday January 07, 2018 @03:11PM (#16092403)
the article mention multiple examples, one of being the "registering things" when it returns the same function untouched, just put away the function instance in a list or something to use it later.
Re:Python decorators they don't tell you about by abhirag on Monday January 08, 2018 @01:00AM (#16094945)
Returning a function would be returning a callable object, which is what I was alluding to. The section under "Decorator Toolbox" contains no suggested usecases for returning a non-callable object, will try and think of something.