{
    "content": [
        {
            "type": "text",
            "text": "# itertools (pydoc)\n\n**Summary:** itertools - Functional tools for creating and using iterators.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (1 lines) — 19 subsections\n  - count (1 lines)\n  - cycle (1 lines)\n  - repeat (1 lines)\n  - accumulate (1 lines)\n  - chain (1 lines)\n  - compress (1 lines)\n  - dropwhile (1 lines)\n  - groupby (1 lines)\n  - filterfalse (1 lines)\n  - islice (1 lines)\n  - pairwise (1 lines)\n  - starmap (1 lines)\n  - tee (1 lines)\n  - takewhile (1 lines)\n  - zip_longest (1 lines)\n  - product (1 lines)\n  - permutations (1 lines)\n  - combinations (1 lines)\n  - combinations_with_replacement (1 lines)\n- **CLASSES** (20 lines) — 18 subsections\n  - class accumulate (27 lines)\n  - class chain (38 lines)\n  - class combinations (32 lines)\n  - class combinations_with_replacement (32 lines)\n  - class compress (27 lines)\n  - class count (34 lines)\n  - class cycle (27 lines)\n  - class dropwhile (29 lines)\n  - class filterfalse (26 lines)\n  - class groupby (34 lines)\n  - class islice (33 lines)\n  - class pairwise (23 lines)\n  - class permutations (32 lines)\n  - class product (42 lines)\n  - class repeat (30 lines)\n  - class starmap (24 lines)\n  - class takewhile (27 lines)\n  - class zip_longest (32 lines)\n- **FUNCTIONS** (1 lines) — 1 subsections\n  - tee (2 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\nitertools - Functional tools for creating and using iterators.\n\n### DESCRIPTION\n\nInfinite iterators:\n\n#### count\n\n#### cycle\n\n#### repeat\n\nIterators terminating on the shortest input sequence:\n\n#### accumulate\n\n#### chain\n\nchain.fromiterable([p, q, ...]) --> p0, p1, ... plast, q0, q1, ...\n\n#### compress\n\n#### dropwhile\n\n#### groupby\n\n#### filterfalse\n\n#### islice\n\nseq[start:stop:step]\n\n#### pairwise\n\n#### starmap\n\n#### tee\n\n#### takewhile\n\n#### zip_longest\n\nCombinatoric generators:\n\n#### product\n\n#### permutations\n\n#### combinations\n\n#### combinations_with_replacement\n\n### CLASSES\n\nbuiltins.object\naccumulate\nchain\ncombinations\ncombinationswithreplacement\ncompress\ncount\ncycle\ndropwhile\nfilterfalse\ngroupby\nislice\npairwise\npermutations\nproduct\nrepeat\nstarmap\ntakewhile\nziplongest\n\n#### class accumulate\n\n|  accumulate(iterable, func=None, *, initial=None)\n|\n|  Return series of accumulated sums (or other binary function results).\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class chain\n\n|  chain(*iterables) --> chain object\n|\n|  Return a chain object whose .next() method returns elements from the\n|  first iterable until it is exhausted, then elements from the next\n|  iterable, until all of the iterables are exhausted.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  classgetitem(...) from builtins.type\n|      See PEP 585\n|\n|  fromiterable(iterable, /) from builtins.type\n|      Alternative chain() constructor taking a single iterable argument that evaluates lazily.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class combinations\n\n|  combinations(iterable, r)\n|\n|  Return successive r-length combinations of elements in the iterable.\n|\n|  combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  sizeof(...)\n|      Returns size in memory, in bytes.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class combinations_with_replacement\n\n|  combinationswithreplacement(iterable, r)\n|\n|  Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.\n|\n|  combinationswithreplacement('ABC', 2) --> ('A','A'), ('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  sizeof(...)\n|      Returns size in memory, in bytes.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class compress\n\n|  compress(data, selectors)\n|\n|  Return data elements corresponding to true selector elements.\n|\n|  Forms a shorter iterator from selected data elements using the selectors to\n|  choose the data elements.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class count\n\n|  count(start=0, step=1)\n|\n|  Return a count object whose .next() method returns consecutive values.\n|\n|  Equivalent to:\n|      def count(firstval=0, step=1):\n|          x = firstval\n|          while 1:\n|              yield x\n|              x += step\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class cycle\n\n|  cycle(iterable, /)\n|\n|  Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class dropwhile\n\n|  dropwhile(predicate, iterable, /)\n|\n|  Drop items from the iterable while predicate(item) is true.\n|\n|  Afterwards, return every element until the iterable is exhausted.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class filterfalse\n\n|  filterfalse(function, iterable, /)\n|\n|  Return those items of iterable for which function(item) is false.\n|\n|  If function is None, return the items that are false.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class groupby\n\n|  groupby(iterable, key=None)\n|\n|  make an iterator that returns consecutive keys and groups from the iterable\n|\n|  iterable\n|    Elements to divide into groups according to the key function.\n|  key\n|    A function for computing the group category for each element.\n|    If the key function is not specified or is None, the element itself\n|    is used for grouping.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class islice\n\n|  islice(iterable, stop) --> islice object\n|  islice(iterable, start, stop[, step]) --> islice object\n|\n|  Return an iterator whose next() method returns selected values from an\n|  iterable.  If start is specified, will skip all preceding elements;\n|  otherwise, start defaults to zero.  Step defaults to one.  If\n|  specified as another value, step determines how many values are\n|  skipped between successive calls.  Works like a slice() on a list\n|  but returns an iterator.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class pairwise\n\n|  pairwise(iterable, /)\n|\n|  Return an iterator of overlapping pairs taken from the input iterator.\n|\n|  s -> (s0,s1), (s1,s2), (s2, s3), ...\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class permutations\n\n|  permutations(iterable, r=None)\n|\n|  Return successive r-length permutations of elements in the iterable.\n|\n|  permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  sizeof(...)\n|      Returns size in memory, in bytes.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class product\n\n|  product(*iterables, repeat=1) --> product object\n|\n|  Cartesian product of input iterables.  Equivalent to nested for-loops.\n|\n|  For example, product(A, B) returns the same as:  ((x,y) for x in A for y in B).\n|  The leftmost iterators are in the outermost for-loop, so the output tuples\n|  cycle in a manner similar to an odometer (with the rightmost element changing\n|  on every iteration).\n|\n|  To compute the product of an iterable with itself, specify the number\n|  of repetitions with the optional repeat keyword argument. For example,\n|  product(A, repeat=4) means the same as product(A, A, A, A).\n|\n|  product('ab', range(3)) --> ('a',0) ('a',1) ('a',2) ('b',0) ('b',1) ('b',2)\n|  product((0,1), (0,1), (0,1)) --> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  sizeof(...)\n|      Returns size in memory, in bytes.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class repeat\n\n|  repeat(object [,times]) -> create an iterator which returns the object\n|  for the specified number of times.  If not specified, returns the object\n|  endlessly.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  lengthhint(...)\n|      Private method returning an estimate of len(list(it)).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class starmap\n\n|  starmap(function, iterable, /)\n|\n|  Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class takewhile\n\n|  takewhile(predicate, iterable, /)\n|\n|  Return successive entries from an iterable as long as the predicate evaluates to true for each entry.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n#### class zip_longest\n\n|  ziplongest(iter1 [,iter2 [...]], [fillvalue=None]) --> ziplongest object\n|\n|  Return a ziplongest object whose .next() method returns a tuple where\n|  the i-th element comes from the i-th iterable argument.  The .next()\n|  method continues until the longest iterable in the argument sequence\n|  is exhausted and then it raises StopIteration.  When the shorter iterables\n|  are exhausted, the fillvalue is substituted in their place.  The fillvalue\n|  defaults to None or can be specified by a keyword argument.\n|\n|  Methods defined here:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  next(self, /)\n|      Implement next(self).\n|\n|  reduce(...)\n|      Return state information for pickling.\n|\n|  setstate(...)\n|      Set state information for unpickling.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n\n### FUNCTIONS\n\n#### tee\n\nReturns a tuple of n independent iterators.\n\n### FILE\n\n(built-in)\n\n"
        }
    ],
    "structuredContent": {
        "command": "itertools",
        "section": "",
        "mode": "pydoc",
        "summary": "itertools - Functional tools for creating and using iterators.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 1,
                "subsections": [
                    {
                        "name": "count",
                        "lines": 1
                    },
                    {
                        "name": "cycle",
                        "lines": 1
                    },
                    {
                        "name": "repeat",
                        "lines": 1
                    },
                    {
                        "name": "accumulate",
                        "lines": 1
                    },
                    {
                        "name": "chain",
                        "lines": 1
                    },
                    {
                        "name": "compress",
                        "lines": 1
                    },
                    {
                        "name": "dropwhile",
                        "lines": 1
                    },
                    {
                        "name": "groupby",
                        "lines": 1
                    },
                    {
                        "name": "filterfalse",
                        "lines": 1
                    },
                    {
                        "name": "islice",
                        "lines": 1
                    },
                    {
                        "name": "pairwise",
                        "lines": 1
                    },
                    {
                        "name": "starmap",
                        "lines": 1
                    },
                    {
                        "name": "tee",
                        "lines": 1
                    },
                    {
                        "name": "takewhile",
                        "lines": 1
                    },
                    {
                        "name": "zip_longest",
                        "lines": 1
                    },
                    {
                        "name": "product",
                        "lines": 1
                    },
                    {
                        "name": "permutations",
                        "lines": 1
                    },
                    {
                        "name": "combinations",
                        "lines": 1
                    },
                    {
                        "name": "combinations_with_replacement",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "CLASSES",
                "lines": 20,
                "subsections": [
                    {
                        "name": "class accumulate",
                        "lines": 27
                    },
                    {
                        "name": "class chain",
                        "lines": 38
                    },
                    {
                        "name": "class combinations",
                        "lines": 32
                    },
                    {
                        "name": "class combinations_with_replacement",
                        "lines": 32
                    },
                    {
                        "name": "class compress",
                        "lines": 27
                    },
                    {
                        "name": "class count",
                        "lines": 34
                    },
                    {
                        "name": "class cycle",
                        "lines": 27
                    },
                    {
                        "name": "class dropwhile",
                        "lines": 29
                    },
                    {
                        "name": "class filterfalse",
                        "lines": 26
                    },
                    {
                        "name": "class groupby",
                        "lines": 34
                    },
                    {
                        "name": "class islice",
                        "lines": 33
                    },
                    {
                        "name": "class pairwise",
                        "lines": 23
                    },
                    {
                        "name": "class permutations",
                        "lines": 32
                    },
                    {
                        "name": "class product",
                        "lines": 42
                    },
                    {
                        "name": "class repeat",
                        "lines": 30
                    },
                    {
                        "name": "class starmap",
                        "lines": 24
                    },
                    {
                        "name": "class takewhile",
                        "lines": 27
                    },
                    {
                        "name": "class zip_longest",
                        "lines": 32
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "tee",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}