

def flatten(what, types=(list, tuple), none_to_empty=False):
    if ((what is None) and none_to_empty):
        return []
    if (not isinstance(what, types)):
        return [what]
    ret = []
    for sub in what:
        ret += flatten(sub, types=types, none_to_empty=none_to_empty)
    return ret

dataset/ETHPy150Open lucasb-eyer/DeepFried2/DeepFried2/utils.py flatten/original