4 examples of 'python repeat list n times' in Python

Every line of 'python repeat list n times' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
13def repeat(object, times = 0):
14 yield object
38def repeat(obj, nrepeat=None):
39 """Generator to repeatedly yield the same object
41 Args:
42 obj (any): The object to yield
44 Kwargs:
45 nrepeat (int): The number of times to repeatedly yield obj
46 """
47 if nrepeat is None:
48 return itertools.repeat(obj)
49 else:
50 return itertools.repeat(obj, times=nrepeat)
657def test_repeat(self):
658 ref = range(0, 1024, 4)
659 ll = dllist(ref)
660 self.assertEqual(ll * 4, dllist(ref * 4))
93def fillRepeat(container, func, n):
94 return container(func() for _ in xrange(n))

Related snippets