python使用函数动态返回类

使用函数动态返回类

 1 def clsp():
 2     props = ['href','value','discrip','big','hashistory']
 3     class point:
 4         def __init__(self):
 5             for key in props:
 6                 if key == 'hashistory':
 7                     setattr(self,key,'disable')
 8                 else:
 9                     setattr(self,key,'')
10             self.href = '/point'
11             self.value = '221'
12 
13         def getprops(self):
14             vals = []    
15             dics =  self.__dict__
16             for idex in range(len(props)):
17                 print dics[props[idex]]
18                 vals.append(dics[props[idex]])
19             print vals
20     return point

 

posted @ 2014-03-19 16:18  Jowhok  阅读(407)  评论(0编辑  收藏  举报