#NEWLINE# def _ensure_element( tup , elem ) : #NEWLINE# #INDENT# '\n    Create a tuple containing all elements of tup, plus elem.\n\n    Returns the new tuple and the index of elem in the new tuple.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# return ( tup , tup . index ( elem ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# return ( tuple ( chain ( elem , ( elem , ) ) ) , len ( tup ) )