def tuplize(seq):
 if isinstance(seq, (list, tuple)):
  return tuple((tuplize(i) for i in seq))
 return seq

def tuplize ( seq ) : if isinstance ( seq , ( list , tuple ) ) : return tuple ( ( tuplize ( i ) for i in seq ) ) return seq
turn all nested sequences to tuples in given sequence .