Exemple #1
0
// HasAttrString returns true if "obj" has the attribute "name".  This is
// equivalent to the Python "hasattr(obj, name)".
func (obj *Base) HasAttrString(name string) bool {
	s := C.CString(name)
	defer C.free(unsafe.Pointer(s))
	ret := C.PyObject_HasAttrString(obj.c(), s)
	if ret == 1 {
		return true
	}
	return false
}
Exemple #2
0
// int PyObject_HasAttrString(PyObject *o, const char *attr_name)
// Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds.
func (self *PyObject) HasAttrString(attr_name string) int {
	c_attr_name := C.CString(attr_name)
	defer C.free(unsafe.Pointer(c_attr_name))

	return int(C.PyObject_HasAttrString(self.ptr, c_attr_name))
}