def py2ldap(val):
 if isinstance(val, bool):
  return (u'TRUE' if val else u'FALSE')
 else:
  return six.text_type(val)

def py2ldap ( val ) : if isinstance ( val , bool ) : return ( u'TRUE' if val else u'FALSE' ) else : return six . text_type ( val )
type convert a python value to a type accepted by ldap .