#!/usr/bin/env python
#-- coding:utf-8 --
“”"
一 functools介绍
1、functools 模块可以说主要是为 函数式编程而设计,用于增强函数功能。
2、functools模块用以 为可调用对象(callable objects)定义高阶函数或操作。
3、functools下面包括:partial
update_wrapper doc
wraps
reduce map reduce
cmp_to_key
lru_cache
singledispatch
二 reduce 字面意思是归纳的意思
三 functools.reduce(function, iterable[, initializer])
方法名是reduce;
第一个参数是function
第二个参数是iterable : 可迭代的
第三个参数是:initializer:初始值;这个参数不是必须的。
四 函数作用:
apply function of two arguments cumulatively to the items of sequence,
这个方法有两个参数,可以对一个序列里面的元素进行累加。python中的序列可以是数组,元组,一切可以迭代的对象。
from left to right,
从 左到右
so as to reduce