[([123],), (None,), (None,), (None,), (None,), (None,), ([65, 66],), ([123],), [123]]
[123, 65, 66, 123, 123]
from itertools import chain
def flatten(seq):
try:
yield from chain.from_iterable(flatten(x) for x in seq if x is not None)
except TypeError:
yield seq
flat_list = list(flatten(lst))
Вместо try/except можно использовать проверку hasattr(seq, '__iter__').def flatten(seq):
try:
yield from chain(*map(flatten, seq))
except TypeError:
yield seq