def flatten(seq):
    """
    >>> flatten([1 , [2, 2], [2, [3, 3, 3]]]) 
    [1, 2, 2, 2, 3, 3, 3]
    """ 
    # flatten fonction from C:\Python26\Lib\compiler\ast.py, 
    # compiler is deprecated in py2.6
    l = []
    for elt in seq:
        t = type(elt)
        if t is tuple or t is list or t is set:
            for elt2 in flatten(elt):
                l.append(elt2)
        else:
            l.append(elt)
    return l