Turning a string into list of positive and negative numbers
converters, list, python, string, tuples
Solution
One method would be to use `ast.literal_eval`:
Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and `None`.
This can be used for safely evaluating strings containing Python expressions from untrusted sources without the need to parse the values oneself.
>>> import ast
>>> ast.literal_eval('1,-2,3,4,-5')
(1, -2, 3, 4, -5)
Problem
If I have a string always in the form `'a,b,c,d,e'` where the letters are positive or negative numbers, e.g `'1,-2,3,4,-5'` and I want to turn it into the tuple e.g (1,-2,3,4,-5), how would I do this?