def _ensure_element(tup, elem):
 try:
  return (tup, tup.index(elem))
 except ValueError:
  return (tuple(chain(tup, (elem,))), len(tup))

def _ensure_element ( tup , elem ) : try : return ( tup , tup . index ( elem ) ) except ValueError : return ( tuple ( chain ( tup , ( elem , ) ) ) , len ( tup ) )
create a tuple containing all elements of tup .