99import itertools
1010import builtins
1111
12- from python_toolbox import nifty_collections
13-
1412infinity = float ('inf' )
1513
1614
@@ -32,10 +30,11 @@ def iterate_overlapping_subsequences(iterable, length=2, wrap_around=False,
3230 If `lazy_tuple=True`, returns a `LazyTuple` rather than an iterator.
3331 '''
3432 iterator = _iterate_overlapping_subsequences (
35- length = length , wrap_around = wrap_around
33+ iterable = iterable , length = length , wrap_around = wrap_around
3634 )
3735
3836 if lazy_tuple :
37+ from python_toolbox import nifty_collections # Avoiding circular import.
3938 return nifty_collections .LazyTuple (iterator )
4039 else :
4140 return iterator
@@ -95,6 +94,7 @@ def shorten(iterable, n, lazy_tuple=False):
9594 iterator = _shorten (iterable = iterable , n = n )
9695
9796 if lazy_tuple :
97+ from python_toolbox import nifty_collections # Avoiding circular import.
9898 return nifty_collections .LazyTuple (iterator )
9999 else :
100100 return iterator
@@ -117,7 +117,7 @@ def _shorten(iterable, n):
117117 raise StopIteration
118118
119119
120- def enumerate (reversible , reverse_index = False ):
120+ def enumerate (reversible , reverse_index = False , lazy_tuple = False ):
121121 '''
122122 Iterate over `(i, item)` pairs, where `i` is the index number of `item`.
123123
@@ -131,6 +131,7 @@ def enumerate(reversible, reverse_index=False):
131131 iterator = _enumerate (reversible = reversible , reverse_index = reverse_index )
132132
133133 if lazy_tuple :
134+ from python_toolbox import nifty_collections # Avoiding circular import.
134135 return nifty_collections .LazyTuple (iterator )
135136 else :
136137 return iterator
@@ -179,6 +180,7 @@ def iter_with(iterable, context_manager, lazy_tuple=False):
179180 iterator = _iter_with (iterable = iterable , context_manager = context_manager )
180181
181182 if lazy_tuple :
183+ from python_toolbox import nifty_collections # Avoiding circular import.
182184 return nifty_collections .LazyTuple (iterator )
183185 else :
184186 return iterator
@@ -254,6 +256,7 @@ def make_false_iterator():
254256 iterators = (make_true_iterator (), make_false_iterator ())
255257
256258 if lazy_tuple :
259+ from python_toolbox import nifty_collections # Avoiding circular import.
257260 return tuple (map (nifty_collections .LazyTuple , iterators ))
258261 else :
259262 return iterators
@@ -297,6 +300,7 @@ def fill(iterable, fill_value=None, fill_value_maker=None, length=infinity,
297300 length = length )
298301
299302 if lazy_tuple :
303+ from python_toolbox import nifty_collections # Avoiding circular import.
300304 return nifty_collections .LazyTuple (iterator )
301305 elif sequence_type is None :
302306 return iterator
0 commit comments