def safeunicode(obj, encoding='utf-8'):
 t = type(obj)
 if (t is text_type):
  return obj
 elif (t is bytes):
  return obj.decode(encoding)
 elif (t in [int, float, bool]):
  return unicode(obj)
 else:
  return unicode(obj)

def safeunicode ( obj , encoding = 'utf-8' ) : t = type ( obj ) if ( t is text_type ) : return obj elif ( t is bytes ) : return obj . decode ( encoding ) elif ( t in [ int , float , bool ] ) : return unicode ( obj ) else : return unicode ( obj )
converts any given object to unicode string .