Programming

Python itertools module

steloflute 2012. 8. 16. 23:30

http://docs.python.org/library/itertools.html

 

This module implements a number of iterator building blocks inspired by constructs from APL, Haskell, and SML. Each has been recast in a form suitable for Python.

 

The module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together, they form an “iterator algebra” making it possible to construct specialized tools succinctly and efficiently in pure Python.

 

 

>>> import itertools
>>> for x in itertools.repeat(10,3): print x

 
10
10
10

 

>>> for x in itertools.islice(itertools.count(0),5):print x

0
1
2
3
4

 

'Programming' 카테고리의 다른 글

Is C Pass by Value or Reference?  (0) 2012.08.21
Python standard input  (0) 2012.08.18
Calling an external command in Python  (0) 2012.08.14
Anonymous function in Go  (0) 2012.08.13
(Javascript) Close window without the prompt message in IE7  (0) 2012.08.13