def force_text(s, encoding='utf-8'):
 if isinstance(s, Text):
  return s
 elif isinstance(s, binary_type):
  return s.decode(encoding)
 else:
  raise TypeError('force_text expects a string type')

def force_text ( s , encoding = 'utf-8' ) : if isinstance ( s , Text ) : return s elif isinstance ( s , binary_type ) : return s . decode ( encoding ) else : raise TypeError ( 'force_text expects a string type' )
converts a string to a text string .