设为首页 加入收藏

TOP

Python装饰器与面向切面编程(四)
2017-09-30 17:54:19 】 浏览:10104
Tags:Python 装饰 面向 编程
=  self ),
67                      ( '__lt__' , lambda  self , other: not  self  > =  other)]
68       }
69       roots =  set ( dir ( cls )) & set (convert)
70       if  not  roots:
71           raise  ValueError( 'must define at least one ordering operation: < > <= >=' )
72       root =  max (roots)       # prefer __lt__ to __le__ to __gt__ to __ge__
73       for  opname, opfunc in  convert[root]:
74           if  opname not  in  roots:
75               opfunc.__name__ =  opname
76               opfunc.__doc__ =  getattr ( int , opname).__doc__
77               setattr ( cls , opname, opfunc)
78       return  cls

本文到这里就全部结束了,有空的话我会整理一个用于检查参数类型的装饰器的源代码放上来,算是一个应用吧 :)

首页 上一页 1 2 3 4 下一页 尾页 4/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇冒泡,递归 下一篇爬虫——多线程糗事百科案例

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目