decorators tutorials
james_027
cai.haibin at gmail.com
Mon Jul 23 10:18:29 EDT 2007
Hi,
> > 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
>
> That looks okay. What is unclear?
>
It just look complicated than using a simple function like this
def check_login(msg):
#...
def my_func(toto, tata):
#...
#call it like this
check_login('msg')
my_func('toto', 'tata')
I hope I could be able to understand clearly the decorators and use it
to it efficiently
Thanks
james
More information about the Python-list
mailing list