I figured out the first two solutions, but the third looks like the most cleaner, think I'll use that one...
Thank you everyone. :) On May 9, 3:24 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > The decorator does receive the correct function. The problem is that > at this point __init__ is still a plain function, not a method, i.e. > the sequence is: > function -> decorated function -> method > > There are several workarounds if you really want to differentiate > between functions and methods, none of them perfect: > > - Apply the decorator after the class has been built, i.e. after the > functions have been wrapped in (unbound) methods: > A.__init__ = w(A.__init__) > > - (Risky Hack): Guess whether a function is intended to be wrapped in > a method by checking whether its first argument is named "self". > Obviously this is not foolproof and it doesn't work for static/class > methods. > > - Have two different decorators, one intended for plain functions and > one for functions-to-be-methods (e.g. @deco, @decomethod). > > George -- http://mail.python.org/mailman/listinfo/python-list