@@ -87,9 +87,9 @@ def _iterate_overlapping_subsequences(iterable, length, wrap_around):
8787 yield tuple (deque )
8888
8989
90- def shorten (iterable , n , lazy_tuple = False ):
90+ def shorten (iterable , length , lazy_tuple = False ):
9191 '''
92- Shorten an iterable to length `n `.
92+ Shorten an iterable to `length `.
9393
9494 Iterate over the given iterable, but stop after `n` iterations (Or when the
9595 iterable stops iteration by itself.)
@@ -98,7 +98,7 @@ def shorten(iterable, n, lazy_tuple=False):
9898
9999 If `lazy_tuple=True`, returns a `LazyTuple` rather than an iterator.
100100 '''
101- iterator = _shorten (iterable = iterable , n = n )
101+ iterator = _shorten (iterable = iterable , length = length )
102102
103103 if lazy_tuple :
104104 from python_toolbox import nifty_collections
@@ -107,20 +107,20 @@ def shorten(iterable, n, lazy_tuple=False):
107107 return iterator
108108
109109
110- def _shorten (iterable , n ):
110+ def _shorten (iterable , length ):
111111
112- if n == infinity :
112+ if length == infinity :
113113 yield from iterable
114114 raise StopIteration
115115
116- assert isinstance (n , int )
116+ assert isinstance (length , int )
117117
118- if n == 0 :
118+ if length == 0 :
119119 raise StopIteration
120120
121121 for i , thing in enumerate (iterable ):
122122 yield thing
123- if i + 1 == n : # Checking `i + 1` to avoid pulling an extra item.
123+ if i + 1 == length : # Checking `i + 1` to avoid pulling an extra item.
124124 raise StopIteration
125125
126126
@@ -152,7 +152,7 @@ def _enumerate(iterable, reverse_index):
152152 try :
153153 length = sequence_tools .get_length (iterable )
154154 except AttributeError :
155- iterable = revenifty_collections .LazyTuple (iterable )
155+ iterable = nifty_collections .LazyTuple (iterable )
156156 length = len (iterable )
157157 return zip (range (length - 1 , - 1 , - 1 ), iterable )
158158
@@ -177,7 +177,7 @@ def get_length(iterable):
177177 If given an iterator, it will be exhausted.
178178 '''
179179 i = 0
180- for thing in iterable :
180+ for _ in iterable :
181181 i += 1
182182 return i
183183
@@ -211,17 +211,17 @@ def _iter_with(iterable, context_manager):
211211 yield next_item
212212
213213
214- def get_items (iterable , n , container_type = tuple ):
214+ def get_items (iterable , n_items , container_type = tuple ):
215215 '''
216- Get the next `n ` items from the iterable as a `tuple`.
216+ Get the next `n_items ` items from the iterable as a `tuple`.
217217
218218 If there are less than `n` items, no exception will be raised. Whatever
219219 items are there will be returned.
220220
221221 If you pass in a different kind of container than `tuple` as
222222 `container_type`, it'll be used to wrap the results.
223223 '''
224- return container_type (shorten (iterable , n ))
224+ return container_type (shorten (iterable , n_items ))
225225
226226
227227def double_filter (filter_function , iterable , lazy_tuple = False ):
@@ -235,7 +235,8 @@ def double_filter(filter_function, iterable, lazy_tuple=False):
235235 Note that this function is not thread-safe. (You may not consume the two
236236 iterators on two separate threads.)
237237
238- If `lazy_tuple=True`, returns two `LazyTuple` objects rather than two iterator.
238+ If `lazy_tuple=True`, returns two `LazyTuple` objects rather than two
239+ iterator.
239240 '''
240241 iterator = iter (iterable )
241242
@@ -396,7 +397,7 @@ def get_single_if_any(iterable,
396397
397398
398399def are_equal (* sequences ):
399- from python_toolbox import sys_tools
400+ '''blocktododoc'''
400401 from python_toolbox import logic_tools
401402 sequence_types = set (map (type , sequences ))
402403
@@ -422,6 +423,7 @@ def are_equal(*sequences):
422423
423424
424425def is_sorted (iterable , key = None ):
426+ '''blocktododoc'''
425427 from python_toolbox import misc_tools
426428 if key is None :
427429 key = misc_tools .identity_function
@@ -490,6 +492,7 @@ def iterate_popitem(item_poppable, lazy_tuple=False):
490492
491493
492494def zip_non_equal (iterables , lazy_tuple = False ):
495+ '''blocktododoc'''
493496 from python_toolbox import logic_tools
494497 iterator = (items for items in zip (* iterables )
495498 if not logic_tools .all_equal (items ))
0 commit comments