Using generator functions can make your example a little easier to read and probably boost the performance.
def flatten(l):for el in l:if isinstance(el, collections.Iterable)andnot isinstance(el, basestring):for sub in flatten(el):yield sub
else:yield el