functools内置装饰器

  

def update_wrapper(wrapper,
wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):


def wraps(wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):

def total_ordering(cls):  用于自动实现类的比较运算。
我们只需要在类中实现 __eq__() 方法和以下方法中的任意一个 __lt__(), __le__(), __gt__(), __ge__(),那么 total_ordering() 就能自动帮我们实现余下的几种比较运算。
示例:
@total_ordering
class Student:
  def __eq__(self, other):
    return ((self.lastname.lower(), self.firstname.lower()) ==
        (other.lastname.lower(), other.firstname.lower()))
  def __lt__(self, other):
    return ((self.lastname.lower(), self.firstname.lower()) <
        (other.lastname.lower(), other.firstname.lower()))


def cmp_to_key(mycmp): 该函数用于将旧式的比较函数转换为关键字函数。
在 Python 3 中,有很多地方都不再支持旧式的比较函数,此时可以使用 cmp_to_key() 进行转换。
示例:
sorted(iterable, key=cmp_to_key(cmp_func))

def reduce(function, sequence, initial=None): # real signature unknown; restored from __doc__


class partial(object):  
原文地址:https://www.cnblogs.com/bayueman/p/6609634.html