I have a list of tuples like:
data = [(\'a1\', \'a2\'), (\'b1\', \'b2\')]
And I want to generate a string like this: \"(\'a1\', \'a2\
\"(\'a1\', \'a2\
Use a generator to cast the tuples to strings and then use join().
join()
>>> ', '.join(str(d) for d in data) "('a1', 'a2'), ('b1', 'b2')"