code: def flatten(x):
      
      # Lifted from: http://stackoverflow.com/a/406822/263969
      result = []
      for el in x:
          if hasattr(el, "__iter__") and not isinstance(el, basestring):
              result.extend(flatten(el))
          else:
              result.append(el)
      return result
docs: Flatten an arbitrary depth nested list.