Decorator functions are static methods for python classes
And now for some random python decorator madness…
Decorators are basically static data created inside a class. The at symbol, ‘@’ is used to signify the beginning of a decorator. The point of static methods is to take a function that does some work, wrap it up some specific way, and return the function back using the original function’s name.
The point of all this? I don’t know, I think it’s pretty useless gobbledygook that provides no benefit or new feature as far as I can see.
Lets say you create a function in some class called MoreStuff()
12 def MoreStuff(self, stuff):return stuff + stuff
Now add a decorator and call it useless.
123 @uselessdef MoreStuff(self, stuff):return stuff + stuff
I don’t know what a Useless decorator might do, but ignore that for a second. Did you know that you call stack decorators and call multiples?
Lets try to give this silly example at least a fraction of usefulness. I’ll add a decorator called logstuff.
1234 @logstuff@uselessdef MoreStuff(self, stuff):return stuff + stuff
If decorators are removed from future versions of python, it will probably happy quietly, without much fuss. Silly example is silly.