无装饰功能组合
compose-func的Python项目详细描述
Important If you prefer to write Python code in a more functional style you may find the toolz package to be more useful, it includes a compose function as well as several functions conducive to writing functional code in Python.
没有魔法运算符或特殊对象,只有一个带有单元测试的函数。这是一个 精心设计的令人胃口大开的例子:
>>> importjson>>> fromcomposeimportcompose>>> fromoperatorimportitemgetter>>> compose((3).__mul__,next,iter,itemgetter('b'),json.loads)('{"a": 1, "b": [2, 3]}')6
贡献
有关开发,请参见http://github.com/jonathanj/compose。
安装
$ pip install compose-func