Decorator function in python part2 -


def request(method="get", path="", data=none):     def wrapper(func):         func.routed = true         func.method = method         func.path = path         func.data = data         return func     return wrapper  def response(fmt="%s", contenttype="text/plain"):     def wrapper(func):         func.format = fmt         func.contenttype = contenttype         return func     return wrapper    @request("get", "%(channel)d/value")     @response("%d")     def digitalread(self, channel):     self.checkdigitalchannel(channel)     return self.__digitalread__(channel) 

from last discussion, talked @a @b def func:

would become func=a()(b() func()) above, @request , @response wrapper how new digitalread function like?

the function have attributes given in wrappers within decorators added it.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -