Python 函数式编程工具箱 Toolz

码农软件 · 软件分类 · 常用工具包 · 2019-08-15 17:57:44

软件介绍

Toolz 是 Python 的函数式编程工具箱。Toolz 支持 Python 2.6+ 和 Python 3.3+。

Toolz 的实现包括三部分:

  • itertoolz,for operations on iterables. 例如:groupby,unique, interpose,

  • functoolz, for higher-order functions. 例如:memoize,curry, compose

  • dicttoolz, for operations on dictionaries. 例如:assoc,update-in, merge.

示例:

>>> def stem(word):
...     """ Stem word to primitive form """
...     return word.lower().rstrip(",.!:;'-\"").lstrip("'\"")
>>> from toolz import compose, frequencies, partial
>>> wordcount = compose(frequencies, partial(map, stem), str.split)
>>> sentence = "This cat jumped over this other cat!"
>>> wordcount(sentence)
{'this': 2, 'cat': 2, 'jumped': 1, 'over': 1, 'other': 1}

本文地址:https://codercto.com/soft/d/12436.html

Python源码剖析

Python源码剖析

陈儒 / 电子工业出版社 / 2008-6 / 69.80元

作为主流的动态语言,Python不仅简单易学、移植性好,而且拥有强大丰富的库的支持。此外,Python强大的可扩展性,让开发人员既可以非常容易地利用C/C++编写Python的扩展模块,还能将Python嵌入到C/C++程序中,为自己的系统添加动态扩展和动态编程的能力。. 为了更好地利用Python语言,无论是使用Python语言本身,还是将Python与C/C++交互使用,深刻理解Pyth......一起来看看 《Python源码剖析》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具