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

Method make_names

Lib/test/test_zipfile/_path/test_complexity.py:42–58  ·  view source on GitHub ↗

>>> list(TestComplexity.make_names(1)) ['a'] >>> list(TestComplexity.make_names(2)) ['a', 'b'] >>> list(TestComplexity.make_names(30)) ['aa', 'ab', ..., 'bd'] >>> list(TestComplexity.make_names(17124)) ['aaa', 'aab', ..., 'zip']

(cls, width, letters=string.ascii_lowercase)

Source from the content-addressed store, hash-verified

40
41 @classmethod
42 def make_names(cls, width, letters=string.ascii_lowercase):
43 """
44 >>> list(TestComplexity.make_names(1))
45 ['a']
46 >>> list(TestComplexity.make_names(2))
47 ['a', 'b']
48 >>> list(TestComplexity.make_names(30))
49 ['aa', 'ab', ..., 'bd']
50 >>> list(TestComplexity.make_names(17124))
51 ['aaa', 'aab', ..., 'zip']
52 """
53 # determine how many products are needed to produce width
54 n_products = max(1, math.ceil(math.log(width, len(letters))))
55 inputs = (letters,) * n_products
56 combinations = itertools.product(*inputs)
57 names = map(''.join, combinations)
58 return itertools.islice(names, width)
59
60 @classmethod
61 def make_deep_paths(cls, depth):

Callers 1

make_zip_pathMethod · 0.95

Calls 2

isliceMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected