Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

flatten an irregular list of lists

def flatten(l):
    for el in l:
        if isinstance(el, collections.Iterable) and not isinstance(el, basestring):
            for sub in flatten(el):
                yield sub
        else:
            yield el
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #flatten #irregular #list #lists
ADD COMMENT
Topic
Name
2+3 =