10 examples of 'convert string of list to list python' in Python

Every line of 'convert string of list to list 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
13def to_list(l):
14 return isinstance(l, list) and l or [l]
84def to_list(value):
85 if value is None:
86 return None
87
88 return list(value)
9def to_python(self, value):
10 return value.split(",")
100def strListToList(strlist):
101 """
102 Convert string in form of '"[33, 42, 43]", "[24, 43, 4]"'
103 into a normal list.
104 """
105
106 strlist = strlist.replace('"', '')
107 strlist = strlist.replace("'", "")
108 try:
109 listeval = ast.literal_eval(strlist)
110 return listeval
111 except ValueError:
112 raise ValueError("Failed to convert %s to list" % (strlist))
6def to_list(obj):
7 if isinstance(obj, list):
8 return obj
9 else:
10 return [obj]
1337def ConvertToPythonStringList(to_convert):
1338 '''
1339 Converts a python string list to a format more suitable for GUI representation
1340 @param to_convert:: The string list
1341 '''
1342 return su.convert_to_string_list(to_convert)
66def to_list(x, default=None):
67 if x is None:
68 return default
69 if not isinstance(x, (list, tuple)):
70 return [x]
71 else:
72 return x
170def makeList(input):
171 if isinstance(input, basestring):
172 return [ input ]
173 elif input is None:
174 return [ ]
175 else:
176 return list(input)
52def list_to_string(list_data):
53 return ', '.join(map(str, list_data))
420def convert_list_str(string_list, type):
421 """
422 Receive a string and then converts it into a list of selected type
423 """
424 new_type_list = (string_list).split(",")
425 for inew_type_list, ele in enumerate(new_type_list):
426 if type is "int":
427 new_type_list[inew_type_list] = int(ele)
428 elif type is "float":
429 new_type_list[inew_type_list] = float(ele)
430
431 return new_type_list

Related snippets