Welcome, guest | Sign In | My Account | Store | Cart
def deepFlatten(lista):
    '''
    >>> list(deepFlatten([1,2,[], [1], 3, [4, [5,6]], 7, 'oi', None])) => [1, 2, 1, 3, 4, 5, 6, 7, 'o', 'i', None]
    '''
    try:
        for item in lista:
            for one in deepFlatten(item):
                yield one
    except:
        yield lista

History

  • revision 2 (14 years ago)
  • previous revisions are not available