james_027 wrote:
> 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
> 
Unfortunately your example isn't equivalent to the decorator version. 
The decorator syntax actually calls the decorator function using the 
following function as its argument, then replaces the function 
definition on with the result of the call on the decorator.

Your example just calls two functions one after the other without any 
relationship being established between them.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to