def flatten_blocks(lines, num_indents=(-1)):
 INDENTATION = (' ' * 4)
 if (not lines):
  return ''
 if isinstance(lines, six.string_types):
  return ((INDENTATION * num_indents) + lines)
 return '\n'.join([flatten_blocks(line, (num_indents + 1)) for line in lines])

def flatten_blocks ( lines , num_indents = ( - 1 ) ) : INDENTATION = ( ' ' * 4 ) if ( not lines ) : return '' if isinstance ( lines , six . string_types ) : return ( ( INDENTATION * num_indents ) + lines ) return '\n' . join ( [ flatten_blocks ( line , ( num_indents + 1 ) ) for line in lines ] )
takes a list or string and flattens it into a string with indentation .