flatten = lambda t: sum(map(flatten, t), ()) if hasattr(t, ‘__iter__’) else (t,)
this is just for tuples
def flatten(tpl):
return sum(map(flatten, tpl), ()) if type(tpl) is tuple else (tpl,)
t= (1, (1, 2, (1, 2, 3), 3))
print flatten(t)
def flatten(tpl):
return sum(map(flatten, tpl), ()) if type(tpl) is tuple else (tpl,)
t= (1, (1, 2, (1, 2, 3), 3))
print flatten(t)