def _ensure_has_len(seq):
 try:
  len(seq)
 except TypeError:
  return list(seq)
 else:
  return seq

def _ensure_has_len ( seq ) : try : len ( seq ) except TypeError : return list ( seq ) else : return seq
if seq is an iterator .