Converting an input string to a list of sub lists with numbers
re.sub(r"\(","",data) is not a very good use of regular expressions. You could have more easily achieved the same result with data.replace("(", "").

But since you are already using regular expressions, why not use them to do more:

&gt;&gt;&gt; re.findall(r'\d+,\d+', "(2,2),(6,2),(2,6)")
['2,2', '6,2', '2,6']


This regular expression finds all digits (\d) (allows also multiple digits using +), which are separated only by a comma. Since different pairs also have parenthesis around them, this just gives you a list of the pairs.

By adding parenthesis around the digits, this captures each of them and splits each pair:

&gt;&gt;&gt; re.findall(r'(\d+),(\d+)', "(2,2),(6,2),(2,6)")
[('2', '2'), ('6', '2'), ('2', '6')]


Now all that is left to do is convert them to integers and put it in a function:

def str_to_nbrs(data):
    return [list(map(int, p)) for p in re.findall(r'(\d+),(\d+)', data)]