Example #1
0
// DelAttrString deletes the attribute with the name "name" from "obj".  This is
// equivalent to the Python "del obj.name".
func (obj *Base) DelAttrString(name string) error {
	s := C.CString(name)
	defer C.free(unsafe.Pointer(s))
	ret := C.PyObject_SetAttrString(obj.c(), s, nil)
	return int2Err(ret)
}
Example #2
0
// int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
// Set the value of the attribute named attr_name, for object o, to the value v. Returns -1 on failure. This is the equivalent of the Python statement o.attr_name = v.
func (self *PyObject) SetAttrString(attr_name string, v *PyObject) int {
	c_attr_name := C.CString(attr_name)
	defer C.free(unsafe.Pointer(c_attr_name))
	return int(C.PyObject_SetAttrString(self.ptr, c_attr_name, v.ptr))
}
Example #3
0
// SetAttrString sets the attribute of "obj" with the name "name" to "value".
// This is equivalent to the Python "obj.name = value".
func (obj *BaseObject) SetAttrString(name string, value Object) error {
	s := C.CString(name)
	defer C.free(unsafe.Pointer(s))
	ret := C.PyObject_SetAttrString(c(obj), s, c(value))
	return int2Err(ret)
}