Q:

Python list to tuple

I have this :
(([75, 0], [100, 0], [100, 370]), ([75, 0], [100, 370], [75, 370])) 

that come from this : 
 [(array([75,  0]), array([100,   0]), array([100, 370])), (array([75,  0]), array([100, 370]), array([ 75, 370]))]

and I want to have : 
[(x1, y1, x2 , y2 ,x3 ,y3), (x1, y1, x2 , y2 ,x3 ,y3), ...] 

or
[(75, 0, 100, 0, 100, 370), (75, 0, 100, 0, 100, 370),.....]

Thanks for the help!

A:

You can use itertools.chain:
import itertools
s = (([75, 0], [100, 0], [100, 370]), ([75, 0], [100, 370], [75, 370])) 
final_s = [list(itertools.chain.from_iterable(i)) for i in s]

Output:
[[75, 0, 100, 0, 100, 370], [75, 0, 100, 370, 75, 370]]

or using reduce in Python2:
s = (([75, 0], [100, 0], [100, 370]), ([75, 0], [100, 370], [75, 370]))    
new_s = [reduce(lambda x, y:list(x)+list(y), i) for i in s]

Output:
[[75, 0, 100, 0, 100, 370], [75, 0, 100, 370, 75, 370]]

