MCPcopy Index your code
hub / github.com/RustPython/RustPython / gen_item

Function gen_item

Lib/test/test_buffer.py:180–186  ·  view source on GitHub ↗

Return single random item.

(fmt, obj)

Source from the content-addressed store, hash-verified

178 return x
179
180def gen_item(fmt, obj):
181 """Return single random item."""
182 mode, chars = fmt.split('#')
183 x = []
184 for c in chars:
185 x.append(randrange_fmt(mode, c, obj))
186 return x[0] if len(x) == 1 else tuple(x)
187
188def gen_items(n, fmt, obj):
189 """Return a list of random items (or a scalar)."""

Callers 3

gen_itemsFunction · 0.85
struct_itemsFunction · 0.85
randitemsFunction · 0.85

Calls 4

randrange_fmtFunction · 0.85
lenFunction · 0.85
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected