#NEWLINE# def partition( self , sep , reverse = False ) : #NEWLINE# #INDENT# '\n        Similar to split, but always creates a tuple with three items:\n\n        1. The part before the separator\n        2. The separator itself.\n        3. The part after.\n\n        We use the same techniques we used in split() to make sure each are\n        colored.\n\n        ' #NEWLINE# if hasattr ( sep , '_clean_string' ) : #NEWLINE# #INDENT# sep = sep . clean ( ) #NEWLINE# #UNINDENT# if reverse : #NEWLINE# #INDENT# parent_result = self . _clean_string . rpartition ( sep ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# parent_result = self . _clean_string . partition ( sep ) #NEWLINE# #UNINDENT# current_index = 0 #NEWLINE# result = tuple ( ) #NEWLINE# for section in parent_result : #NEWLINE# #INDENT# result += ( self [ current_index : ( current_index + len ( section ) ) ] , ) #NEWLINE# current_index += len ( section ) #NEWLINE# #UNINDENT# return result