Почему decorator не может украсить статический метод или метод класса?
from decorator import decorator
@decorator
def print_function_name(function, *args):
print '%s was called.' % function.func_name
return function(*args)
class My_class(object):
@print_function_name
@classmethod
def get_dir(cls):
return dir(cls)
@print_function_name
@staticmethod
def get_a():
return 'a'
И get_dir и get_a приводят к AttributeError: <'classmethod' or 'staticmethod'>, object has no attribute '__name__'.
Почему decorator полагается на атрибут __name__ вместо атрибута func_name? (Во всех функциях, включая методы классов и статические методы, есть атрибут func_name.)
Редактировать: я использую Python 2.6.