My Input is:
input = ['(var1, )', '(var2,var3)']
Expected Output is:
output = [('var1', ), ('var2','var3')]
Iterating over input and using eval
/literal_eval
on the tuple-strings is not possible:
>>> eval('(var1, )')
>>> NameError: name 'var1' is not defined
How can I convert an item such as '(var1, )'
to a tuple where the inner objects are treated as strings instead of variables?
Is there a simpler way than writing a parser or using regex?