69 class CItem(object):
70 def __init__(self):
71 setattr(self,'__delxx__',self.fun(self.__delxx__))
72 @staticmethod
73 def fun(fn):
74 print 'in fun'
75 fn()()
76 @staticmethod
77 def __delxx__():
78 print 'del'
79 def local_fun():
80 print 'local fun'
81 return local_fun
82 if __name__ == '__main__':
83 import time
84 it=CItem()
85 it.__delxx__##装饰器
86 #it.fun()
common> ./mypthon
in fun
del
local fun
********************************************************************************
69 class CItem(object):
70 def __init__(self):
71 setattr(self,'__delxx__',self.fun(self.__delxx__))
72 @staticmethod
73 def fun(fn):
74 print 'in fun'
75 def local_fun(*args):
76 print 'local fun'
77 print '%s'%args
78 fn()
79 return local_fun
80
81 @staticmethod
82 def __delxx__():
83 print 'del'
84 if __name__ == '__main__':
85 import time
86 it=CItem()
87 it.__delxx__('apple')
8/common> ./mypthon
in fun
local fun
apple
del