Every line of 'how to make a list of a certain length in python' 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.
170 def makeList(input): 171 if isinstance(input, basestring): 172 return [ input ] 173 elif input is None: 174 return [ ] 175 else: 176 return list(input)
13 def to_list(l): 14 return isinstance(l, list) and l or [l]
22 def bunch(lst, size): 23 size = int(size) 24 return [lst[i:i+size] for i in range(0, len(lst), size)]
814 def unlist(l): 815 """ 816 Macht aus einer Liste mit nur einem Element einen Skalar. 817 """ 818 if len(l) == 1: 819 return l[0] 820 return l
3 def newlist(size): 4 list = [] 5 for i in range(size): 6 list.append(i) 7 return list
76 def make_list(**kwargs): 77 return [ 78 { 79 "value": ["hello", "world"], 80 "simplified": ( 81 CODE[list], 82 ((CODE[str], (b"hello",)), (CODE[str], (b"world",))), # item 83 ), 84 }, 85 {"value": ["hello"], "simplified": (CODE[list], ((CODE[str], (b"hello",)),))}, # item 86 {"value": [], "simplified": (CODE[list], tuple())}, 87 # Tests that forced full simplify should return just simplified object if it doesn't have full simplifier 88 { 89 "forced": True, 90 "value": ["hello"], 91 "simplified": (CODE[list], ((CODE[str], (b"hello",)),)), # item 92 }, 93 ]
26 def listify(l): 27 if isinstance(l, types.StringTypes): 28 l = [l] 29 return l
456 def allocate_python(value): 457 assert not isinstance(value, str), (type(value), repr(value)) 458 # Allocate some handle to hold VALUE, return its index. 459 if freed_list: 460 index = freed_list[-1] 461 del freed_list[-1] 462 python[index] = value 463 else: 464 index = len(python) 465 python.append(value) 466 return index
54 def test_to_list_one_item(lla): 55 lla.append(1) 56 57 assert lla.to_list() == [1]