code: def flatten(obj, isinstance=isinstance, StringTypes=StringTypes,
              SequenceTypes=SequenceTypes, do_flatten=do_flatten):
      
      if isinstance(obj, StringTypes) or not isinstance(obj, SequenceTypes):
          return [obj]
      result = []
      for item in obj:
          if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes):
              result.append(item)
          else:
              do_flatten(item, result)
      return result
docs: Flatten a sequence to a non-nested list.
  
      Flatten() converts either a single scalar or a nested sequence
      to a non-nested list. Note that flatten() considers strings
      to be scalars instead of sequences like Python would.