itertools

Doc: https://docs.python.org/2/library/itertools.html

any(iterable): returns True if at least one element of an iterable is true.

all(iterable): returns True if all elements of an iterable is true.

zip(): combines the elements of several iterators into tuples.

for item in zip([1, 2, 3], ['a', 'b', 'c']):
    print(item)

for index, e in zip([1, 2, 3], ['a', 'b', 'c', 'd']):
    print("{}:{}".format(index, e))

islice(): same as slice() but it returns an iterator instead of a list.

count(): returns an iterator that produces consecutive integers indefinitely. The first number can be passed as an argument, the default is zero.

chain(): takes several iterators as arguments and returns a single iterator that produces the contents of all of them as though they came from a single sequence.

results matching ""

    No results matching ""