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

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