MCPcopy
hub / github.com/Textualize/rich / loop_last

Function loop_last

rich/_loop.py:18–28  ·  rich/_loop.py::loop_last

Iterate and generate a tuple with a flag for last value.

(values: Iterable[T])

Source from the content-addressed store, hash-verified

16
17
18def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
19 class="st">""class="st">"Iterate and generate a tuple with a flag for last value."class="st">""
20 iter_values = iter(values)
21 try:
22 previous_value = next(iter_values)
23 except StopIteration:
24 return
25 for value in iter_values:
26 yield False, previous_value
27 previous_value = value
28 yield True, previous_value
29
30
31def loop_first_last(values: Iterable[T]) -> Iterable[Tuple[bool, bool, T]]:

Callers 14

test_loop_lastFunction · 0.90
iter_textMethod · 0.85
get_topMethod · 0.85
get_rowMethod · 0.85
get_bottomMethod · 0.85
render_stackMethod · 0.85
__rich_console__Method · 0.85
__rich_console__Method · 0.85
expandMethod · 0.85
_traverseFunction · 0.85
_renderMethod · 0.85
__rich_console__Method · 0.85

Calls

no outgoing calls

Tested by 1

test_loop_lastFunction · 0.72