10 examples of 'python split list of tuples' in Python

Every line of 'python split list of tuples' 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
286def _split_list(value):
287 """Split a string list into parts."""
288 if value:
289 return [p for p in LIST_SEP_RE.split(value) if p]
290 else:
291 return []
1def split_list(l, parts=1):
2 """
3 Splits a list into even pieces.
4 :param l: list
5 :param parts: number of parts
6 :return: list of lists
7 """
8 length = len(l)
9 return [l[i * length // parts: (i + 1) * length // parts]
10 for i in range(parts)]
30def as_tuple(value):
31 '''
32 Smart cast value to tuple by splittng the input on ",".
33 '''
34 if isinstance(value, tuple):
35 return value
36 return tuple(as_list(value))
37def _itersplit(l, splitters):
38 current = []
39 for item in l:
40 if item in splitters:
41 yield current
42 current = []
43 else:
44 current.append(item)
45 yield current
67def tuple(
68 arg: builtins.str, default: builtins.tuple = None
69) -> Optional[builtins.tuple]:
70 val_list: Optional[List[Any]] = list(arg, default=default)
71
72 if val_list is not None:
73 return builtins.tuple(val_list)
74 else:
75 try:
76 return default
77 except TypeError:
78 return None
233def split_list(self, alist, wanted_parts=1):
234 length = len(alist)
235 return [alist[i*length // wanted_parts: (i+1)*length // wanted_parts]
236 for i in range(wanted_parts)]
6def split(v, *counts):
7 r = []
8 offset = 0
9 for n in counts:
10 if n != 0:
11 r.append(v[offset:offset+n])
12 else:
13 r.append(None)
14 offset += n
15 return tuple(r)
14def split(alist):
15 if len(alist)>1:
16 mid = len(alist)//2
17 lefthalf = split(alist[:mid])
18 righthalf = split(alist[mid:])
19
20 return merge(lefthalf,righthalf)
21 return alist[0]
156def as_list(value):
157 values = as_cr_separated_list(value)
158 result = []
159 for value in values:
160 if isinstance(value, string_types):
161 subvalues = value.split()
162 result.extend(subvalues)
163 else:
164 result.append(value)
165 return result
118def convert_list_comma(s):
119 """
120 Return a list object from the <s>.
121 Consider <s> is comma delimited.
122 """
123 if s is None:
124 return []
125 if isinstance(s, list):
126 return s
127 return [word for word in re.split(r"\s*,\s*", s.strip()) if word != ""]</s></s>

Related snippets