Fully flattens an iterable:
    In: flatten([1,2,3,4,[5,6,[7,8]]])
    Out: [1,2,3,4,5,6,7,8]

def flatten(iterable):
    """Fully flattens an iterable:
    In: flatten([1,2,3,4,[5,6,[7,8]]])
    Out: [1,2,3,4,5,6,7,8]
    """
    container = iterable.__class__

    placeholder = []
    for item in iterable:
        try:
            placeholder.extend(flatten(item))
        except TypeError:
            placeholder.append(item)

    return container(placeholder)