def strip_whitespace(tokens):
 for (i, token) in enumerate(tokens):
  if (token.type != u'S'):
   break
 else:
  return []
 tokens = tokens[i:]
 while (tokens and (tokens[(-1)].type == u'S')):
  tokens.pop()
 return tokens

def strip_whitespace ( tokens ) : for ( i , token ) in enumerate ( tokens ) : if ( token . type != u'S' ) : break else : return [ ] tokens = tokens [ i : ] while ( tokens and ( tokens [ ( - 1 ) ] . type == u'S' ) ) : tokens . pop ( ) return tokens
remove whitespace from a text or byte string .