decorators question

Fredrik Lundh fredrik at pythonware.com
Mon Dec 4 13:10:41 EST 2006


king kikapu wrote:

> It will load all the module, all the functions and when it sees that
> some function(s) are decorating, then it will start execute respectives
> decorators ?

     @decorator
     def func():
         pass

is *exactly* the same thing as:

     def func():
         pass
     func = decorator(func)

> And this will do it for all decorated functions ?? Even if we do not
> have any references to these functions ?

Python calls the decorator, not the decorated function.

additional reading:

     http://www.python.org/doc/2.4.4/whatsnew/node6.html
     http://www.python.org/dev/peps/pep-0318

and the relevant chapters in the tutorial and the language reference.

</F>




More information about the Python-list mailing list