Join a list of tuples with a formatting in an efficient manner
You can use the str.join
method with a generator expression like the following:
' '.join('(%s)' % ','.join(map(str, t)) for t in a)
This returns a string with the following content:
(5,2) (2,4)