How to destack nested tuples in Python?
How to convert the following tuple:
from:
(('aa', 'bb', 'cc'), 'dd')
to:
('aa', 'bb', 'cc', 'dd')
l = (('aa', 'bb', 'cc'), 'dd')
l = l[0] + (l[1],)
This will work for your situation, however John La Rooy's solution is better for general cases.
a = (1, 2)
b = (3, 4)
x = a + b
print(x)
Out:
(1, 2, 3, 4)
>>> tuple(j for i in (('aa', 'bb', 'cc'), 'dd') for j in (i if isinstance(i, tuple) else (i,)))
('aa', 'bb', 'cc', 'dd')