Without using inspect i will do it like this:
import types
def trace(cls):
for attr_name in cls.__dict__:
attr = getattr(cls, attr_name)
if isinstance(attr, types.MethodType):
setattr(cls, attr_name, log(attr))
return cls
EDIT:
Your constrain are a bit weird but let see :
We can replace if isinstance(attr, types.MethodType)
by if callable(attr)
this will give us only callable attribute of the class which include also static methods and class methods ...
We can also do as the other answer suggest use if hasattr(attr, 'im_func')
this will exclude the static methods.
If we want to exclude class method too (only get instance method), i think the only solution i'm aware off now (without importing an other module) is by changing the decorator to check if the first argument is a class or an instance, this can give you a hint if the method that will be decorated is a class or a instance method.
Hope it help :)