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()

Now add a decorator and call it useless.

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.

If decorators are removed from future versions of python, it will probably happy quietly, without much fuss. Silly example is silly.


Posted on May 1st, by admica in python.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">