def _to_str(value):
 if isinstance(value, unicode):
  return value.encode('utf-8')
 return value

def _to_str ( value ) : if isinstance ( value , unicode ) : return value . encode ( 'utf-8' ) return value
helper function to make sure unicode values converted to utf-8 args: value: str or unicode to convert to utf-8 .