Hi all, I am having difficulty understanding decorator. The definition was clear for me, but the syntax is not so clear to me.
will decorators will always have to be in this way def check_login(func): def _check_login(*args): print "I am decorator" return func(*args) return _check_login @check_login def method2(input): print "I am method TWO. Input %s" % input james On Jul 23, 4:41 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > james_027 wrote: > > Hi, > > > I am learning python by learning django, and I stumble upon decorator > > which is very cool, any beginners resources for python decorators, > > although I can google it, I just want to get a good tutorial for this > > topic. > > Decorators are just a more concise but less obvious way of calling a > defined function on another function. > > e.g. > @my_decorator > def foo(): > ... > > is the essentially the same as: > > def foo(): > ... > foo=my_decorator(foo) -- http://mail.python.org/mailman/listinfo/python-list