# itertools - pydoc - phpman

Help on built-in module itertools:

## NAME
    itertools - Functional tools for creating and using iterators.

## DESCRIPTION
    Infinite iterators:
### count
### cycle
### repeat

    Iterators terminating on the shortest input sequence:
### accumulate
### chain
    chain.from_iterable([p, q, ...]) --> p0, p1, ... plast, q0, q1, ...
### compress
### dropwhile
### groupby
### filterfalse
### islice
           seq[start:stop:step]
### pairwise
### starmap
### tee
### takewhile
### zip_longest

    Combinatoric generators:
### product
### permutations
### combinations
### combinations_with_replacement

## CLASSES
    builtins.object
        accumulate
        chain
        combinations
        combinations_with_replacement
        compress
        count
        cycle
        dropwhile
        filterfalse
        groupby
        islice
        pairwise
        permutations
        product
        repeat
        starmap
        takewhile
        zip_longest

### class accumulate
     |  accumulate(iterable, func=None, *, initial=None)
     |
     |  Return series of accumulated sums (or other binary function results).
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class chain
     |  chain(*iterables) --> chain object
     |
     |  Return a chain object whose .__next__() method returns elements from the
     |  first iterable until it is exhausted, then elements from the next
     |  iterable, until all of the iterables are exhausted.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |
     |  __class_getitem__(...) from builtins.type
     |      See PEP 585
     |
     |  from_iterable(iterable, /) from builtins.type
     |      Alternative chain() constructor taking a single iterable argument that evaluates lazily.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class combinations
     |  combinations(iterable, r)
     |
     |  Return successive r-length combinations of elements in the iterable.
     |
     |  combinations([range(4)](https://www.chedong.com/phpMan.php/man/range/4/markdown), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  __sizeof__(...)
     |      Returns size in memory, in bytes.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class combinations_with_replacement
     |  combinations_with_replacement(iterable, r)
     |
     |  Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.
     |
     |  combinations_with_replacement('ABC', 2) --> ('A','A'), ('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  __sizeof__(...)
     |      Returns size in memory, in bytes.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class compress
     |  compress(data, selectors)
     |
     |  Return data elements corresponding to true selector elements.
     |
     |  Forms a shorter iterator from selected data elements using the selectors to
     |  choose the data elements.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class count
     |  count(start=0, step=1)
     |
     |  Return a count object whose .__next__() method returns consecutive values.
     |
     |  Equivalent to:
     |      def count(firstval=0, step=1):
     |          x = firstval
     |          while 1:
     |              yield x
     |              x += step
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class cycle
     |  cycle(iterable, /)
     |
     |  Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class dropwhile
     |  dropwhile(predicate, iterable, /)
     |
     |  Drop items from the iterable while predicate(item) is true.
     |
     |  Afterwards, return every element until the iterable is exhausted.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class filterfalse
     |  filterfalse(function, iterable, /)
     |
     |  Return those items of iterable for which function(item) is false.
     |
     |  If function is None, return the items that are false.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class groupby
     |  groupby(iterable, key=None)
     |
     |  make an iterator that returns consecutive keys and groups from the iterable
     |
     |  iterable
     |    Elements to divide into groups according to the key function.
     |  key
     |    A function for computing the group category for each element.
     |    If the key function is not specified or is None, the element itself
     |    is used for grouping.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class islice
     |  islice(iterable, stop) --> islice object
     |  islice(iterable, start, stop[, step]) --> islice object
     |
     |  Return an iterator whose next() method returns selected values from an
     |  iterable.  If start is specified, will skip all preceding elements;
     |  otherwise, start defaults to zero.  Step defaults to one.  If
     |  specified as another value, step determines how many values are
     |  skipped between successive calls.  Works like a slice() on a list
     |  but returns an iterator.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class pairwise
     |  pairwise(iterable, /)
     |
     |  Return an iterator of overlapping pairs taken from the input iterator.
     |
     |  s -> (s0,s1), (s1,s2), (s2, s3), ...
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class permutations
     |  permutations(iterable, r=None)
     |
     |  Return successive r-length permutations of elements in the iterable.
     |
     |  permutations([range(3)](https://www.chedong.com/phpMan.php/man/range/3/markdown), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  __sizeof__(...)
     |      Returns size in memory, in bytes.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class product
     |  product(*iterables, repeat=1) --> product object
     |
     |  Cartesian product of input iterables.  Equivalent to nested for-loops.
     |
     |  For example, product(A, B) returns the same as:  ((x,y) for x in A for y in B).
     |  The leftmost iterators are in the outermost for-loop, so the output tuples
     |  cycle in a manner similar to an odometer (with the rightmost element changing
     |  on every iteration).
     |
     |  To compute the product of an iterable with itself, specify the number
     |  of repetitions with the optional repeat keyword argument. For example,
     |  product(A, repeat=4) means the same as product(A, A, A, A).
     |
     |  product('ab', [range(3)](https://www.chedong.com/phpMan.php/man/range/3/markdown)) --> ('a',0) ('a',1) ('a',2) ('b',0) ('b',1) ('b',2)
     |  product((0,1), (0,1), (0,1)) --> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  __sizeof__(...)
     |      Returns size in memory, in bytes.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class repeat
     |  repeat(object [,times]) -> create an iterator which returns the object
     |  for the specified number of times.  If not specified, returns the object
     |  endlessly.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __length_hint__(...)
     |      Private method returning an estimate of len(list(it)).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class starmap
     |  starmap(function, iterable, /)
     |
     |  Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class takewhile
     |  takewhile(predicate, iterable, /)
     |
     |  Return successive entries from an iterable as long as the predicate evaluates to true for each entry.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class zip_longest
     |  zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) --> zip_longest object
     |
     |  Return a zip_longest object whose .__next__() method returns a tuple where
     |  the i-th element comes from the i-th iterable argument.  The .__next__()
     |  method continues until the longest iterable in the argument sequence
     |  is exhausted and then it raises StopIteration.  When the shorter iterables
     |  are exhausted, the fillvalue is substituted in their place.  The fillvalue
     |  defaults to None or can be specified by a keyword argument.
     |
     |  Methods defined here:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __iter__(self, /)
     |      Implement iter(self).
     |
     |  __next__(self, /)
     |      Implement next(self).
     |
     |  __reduce__(...)
     |      Return state information for pickling.
     |
     |  __setstate__(...)
     |      Set state information for unpickling.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

## FUNCTIONS
### tee
        Returns a tuple of n independent iterators.

## FILE
    (built-in)


