def change_lists_to_sets(iterable):
 if isinstance(iterable, dict):
  for key in iterable:
   if isinstance(iterable[key], (list, tuple)):
    try:
     iterable[key] = set(iterable[key])
    except TypeError:
     pass
   elif getattr(iterable[key], '__iter__', False):
    change_lists_to_sets(iterable[key])
 elif isinstance(iterable, (list, tuple)):
  for item in iterable:
   if isinstance(item, (list, tuple)):
    iterable.pop(item)
    iterable.append(set(item))
   elif getattr(item, '__iter__', False):
    change_lists_to_sets(item)
 else:
  raise NotImplementedError

def change_lists_to_sets ( iterable ) : if isinstance ( iterable , dict ) : for key in iterable : if isinstance ( iterable [ key ] , ( list , tuple ) ) : try : iterable [ key ] = set ( iterable [ key ] ) except TypeError : pass elif getattr ( iterable [ key ] , '__iter__' , False ) : change_lists_to_sets ( iterable [ key ] ) elif isinstance ( iterable , ( list , tuple ) ) : for item in iterable : if isinstance ( item , ( list , tuple ) ) : iterable . pop ( item ) iterable . append ( set ( item ) ) elif getattr ( item , '__iter__' , False ) : change_lists_to_sets ( item ) else : raise NotImplementedError
convert any lists or tuples in iterable into sets .