Differences between class and function decorator

Duncan Booth duncan.booth at invalid.invalid
Fri Jan 16 14:38:21 EST 2009


mk <mrkafk at gmail.com> wrote:

> Note that function decorator returned None, while class decorator 
> returned function.
> 
> Why the difference in behavior? After all, print_method_name decorator 
> also returns a function (well it's a new function but still a function)?

That would be because the function decorator returns the result of calling 
the function whereas your class decorator simply returns the function 
without calling it.



More information about the Python-list mailing list