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

Function loop_first

rich/_loop.py:6–15  ·  view source on GitHub ↗

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

(values: Iterable[T])

Source from the content-addressed store, hash-verified

4
5
6def loop_first(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
7 """Iterate and generate a tuple with a flag for first value."""
8 iter_values = iter(values)
9 try:
10 value = next(iter_values)
11 except StopIteration:
12 return
13 yield True, value
14 for value in iter_values:
15 yield False, value
16
17
18def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:

Callers 5

test_loop_firstFunction · 0.90
_get_syntaxMethod · 0.85
__rich_console__Method · 0.85
render_bulletMethod · 0.85
render_numberMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_loop_firstFunction · 0.72