On Sun, Mar 9, 2008 at 6:31 AM, Greg Ewing <[EMAIL PROTECTED]> wrote:
>
>  No, a wrapper can't distinguish between a plain function and
>  an unbound method this way, because it gets called before the
>  function is put into a class. So it's always wrapping a plain
>  function, not an unbound method object.
>

Witness:

>>> def wraptest(func):
...     print "I'm wrapping an instance of ", type(func)
...     return func
...
>>> class C(object):
...     @wraptest
...     @staticmethod
...     def s():
...         pass
...     @wraptest
...     @classmethod
...     def c():
...         pass
...     @wraptest
...     def i():
...         pass
...
I'm wrapping an instance of  <type 'staticmethod'>
I'm wrapping an instance of  <type 'classmethod'>
I'm wrapping an instance of  <type 'function'>
>>>
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to