Lines Matching refs:iterable
54 :func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v)
94 Make an iterator that returns elements from the first iterable until it is
95 exhausted, then proceeds to the next iterable, until all of the iterables are
106 .. classmethod:: chain.from_iterable(iterable)
109 single iterable argument that is evaluated lazily. Roughly equivalent to::
120 .. function:: combinations(iterable, r)
122 Return *r* length subsequences of elements from the input *iterable*.
125 input *iterable* is sorted, the combination tuples will be produced
134 def combinations(iterable, r):
137 pool = tuple(iterable)
158 def combinations(iterable, r):
159 pool = tuple(iterable)
170 .. function:: combinations_with_replacement(iterable, r)
172 Return *r* length subsequences of elements from the input *iterable*
176 input *iterable* is sorted, the combination tuples will be produced
185 def combinations_with_replacement(iterable, r):
187 pool = tuple(iterable)
206 def combinations_with_replacement(iterable, r):
207 pool = tuple(iterable)
252 .. function:: cycle(iterable)
254 Make an iterator returning elements from the iterable and saving a copy of each.
255 When the iterable is exhausted, return elements from the saved copy. Repeats
258 def cycle(iterable):
261 for element in iterable:
269 (depending on the length of the iterable).
272 .. function:: dropwhile(predicate, iterable)
274 Make an iterator that drops elements from the iterable as long as the predicate
279 def dropwhile(predicate, iterable):
281 iterable = iter(iterable)
282 for x in iterable:
286 for x in iterable:
290 .. function:: groupby(iterable[, key])
292 Make an iterator that returns consecutive keys and groups from the *iterable*.
295 the element unchanged. Generally, the iterable needs to already be sorted on
304 The returned group is itself an iterator that shares the underlying iterable
321 def __init__(self, iterable, key=None):
325 self.it = iter(iterable)
344 .. function:: ifilter(predicate, iterable)
346 Make an iterator that filters elements from iterable returning only those for
350 def ifilter(predicate, iterable):
354 for x in iterable:
359 .. function:: ifilterfalse(predicate, iterable)
361 Make an iterator that filters elements from iterable returning only those for
365 def ifilterfalse(predicate, iterable):
369 for x in iterable:
378 arguments as a tuple. Like :func:`map` but stops when the shortest iterable is
395 .. function:: islice(iterable, stop)
396 islice(iterable, start, stop[, step])
398 Make an iterator that returns selected elements from the iterable. If *start* is
399 non-zero, then elements from the iterable are skipped until start is reached.
408 def islice(iterable, *args):
416 for i, element in enumerate(iterable):
457 Iteration continues until the longest iterable is exhausted. Roughly equivalent to::
486 .. function:: permutations(iterable[, r])
488 Return successive *r* length permutations of elements in the *iterable*.
491 of the *iterable* and all possible full-length permutations
495 input *iterable* is sorted, the permutation tuples will be produced
504 def permutations(iterable, r=None):
507 pool = tuple(iterable)
533 def permutations(iterable, r=None):
534 pool = tuple(iterable)
558 To compute the product of an iterable with itself, specify the number of
599 .. function:: starmap(function, iterable)
602 the iterable. Used instead of :func:`imap` when argument parameters are already
603 grouped in tuples from a single iterable (the data has been "pre-zipped"). The
607 def starmap(function, iterable):
609 for args in iterable:
614 Now, any iterable is allowed.
616 .. function:: takewhile(predicate, iterable)
618 Make an iterator that returns elements from the iterable as long as the
621 def takewhile(predicate, iterable):
623 for x in iterable:
630 .. function:: tee(iterable[, n=2])
632 Return *n* independent iterators from a single iterable. Roughly equivalent to::
634 def tee(iterable, n=2):
635 it = iter(iterable)
646 Once :func:`tee` has made a split, the original *iterable* should not be
647 used anywhere else; otherwise, the *iterable* could get advanced without
668 rather than bringing the whole iterable into memory all at once. Code volume is
676 def take(n, iterable):
677 "Return first n items of the iterable as a list"
678 return list(islice(iterable, n))
694 def nth(iterable, n, default=None):
696 return next(islice(iterable, n, None), default)
698 def all_equal(iterable):
700 g = groupby(iterable)
703 def quantify(iterable, pred=bool):
705 return sum(imap(pred, iterable))
707 def padnone(iterable):
712 return chain(iterable, repeat(None))
714 def ncycles(iterable, n):
716 return chain.from_iterable(repeat(tuple(iterable), n))
734 def pairwise(iterable):
736 a, b = tee(iterable)
740 def grouper(iterable, n, fillvalue=None):
743 args = [iter(iterable)] * n
759 def powerset(iterable):
761 s = list(iterable)
764 def unique_everseen(iterable, key=None):
771 for element in ifilterfalse(seen.__contains__, iterable):
775 for element in iterable:
781 def unique_justseen(iterable, key=None):
785 return imap(next, imap(itemgetter(1), groupby(iterable, key)))
816 def random_permutation(iterable, r=None):
817 "Random selection from itertools.permutations(iterable, r)"
818 pool = tuple(iterable)
822 def random_combination(iterable, r):
823 "Random selection from itertools.combinations(iterable, r)"
824 pool = tuple(iterable)
829 def random_combination_with_replacement(iterable, r):
830 "Random selection from itertools.combinations_with_replacement(iterable, r)"
831 pool = tuple(iterable)