MCPcopy Index your code
hub / github.com/python/cpython / choose_lines

Function choose_lines

Lib/test/test_zlib.py:975–980  ·  view source on GitHub ↗

Return a list of number lines randomly chosen from the source

(source, number, seed=None, generator=random)

Source from the content-addressed store, hash-verified

973 self.assertEqual(expected, actual)
974
975def choose_lines(source, number, seed=None, generator=random):
976 """Return a list of number lines randomly chosen from the source"""
977 if seed is not None:
978 generator.seed(seed)
979 sources = source.split('\n')
980 return [generator.choice(sources) for n in range(number)]
981
982
983HAMLET_SCENE = b"""

Callers

nothing calls this directly

Calls 3

choiceMethod · 0.80
seedMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…