#NEWLINE# def strip_whitespace( tokens ) : #NEWLINE# #INDENT# 'Remove whitespace at the beggining and end of a token list.\n\n    Whitespace tokens in-between other tokens in the list are preserved.\n\n    :param tokens:\n        A list of :class:`~.token_data.Token` or\n        :class:`~.token_data.ContainerToken`.\n    :return:\n        A new sub-sequence of the list.\n\n    ' #NEWLINE# for ( i , token ) in enumerate ( tokens ) : #NEWLINE# #INDENT# if ( token . type != 'S' ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# tokens = tokens [ i : ] #NEWLINE# while ( tokens and ( tokens [ ( - 1 ) ] . type == 'S' ) ) : #NEWLINE# #INDENT# tokens . pop ( ) #NEWLINE# #UNINDENT# return tokens