decorators question

king kikapu aboudouvas at panafonet.gr
Mon Dec 4 14:10:28 EST 2006


>      def func():
>          pass
>
> is *exactly* the same thing as:
>
>      def func():
>          pass
>      func = decorator(func)

Yes, i know that but i thought that it is so when I call the function,
not when the runtime just loads the module...



>Python calls the decorator, not the decorated function.


Hmmm...ok...it calls the decorator but when ?? It (the runtime) loads
the .py file and start to call every decorator
it finds on it, regardless of the existance of code that actually calls
the decorated functions ??
I understand thet Python does not call the decoratated functiond but it
ends up this way...


>
> 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.
> 

I will have a lokk also thera, thanks!

> </F>




More information about the Python-list mailing list