def strip_none(data, omit_none=False):
 if (data is None):
  data = '~'
 elif isinstance(data, list):
  data2 = []
  for x in data:
   if (omit_none and (x is None)):
    pass
   else:
    data2.append(strip_none(x))
  return data2
 elif isinstance(data, dict):
  data2 = {}
  for key in data.keys():
   if (omit_none and (data[key] is None)):
    pass
   else:
    data2[str(key)] = strip_none(data[key])
  return data2
 return data

def strip_none ( data , omit_none = False ) : if ( data is None ) : data = '~' elif isinstance ( data , list ) : data2 = [ ] for x in data : if ( omit_none and ( x is None ) ) : pass else : data2 . append ( strip_none ( x ) ) return data2 elif isinstance ( data , dict ) : data2 = { } for key in data . keys ( ) : if ( omit_none and ( data [ key ] is None ) ) : pass else : data2 [ str ( key ) ] = strip_none ( data [ key ] ) return data2 return data
returns a dictionary stripped of any keys having values of none .