SetAttrString set the value of the attribute provided for this object to the specified value.
(name string, value *C.PyObject)
| 237 | |
| 238 | // SetAttrString set the value of the attribute provided for this object to the specified value. |
| 239 | func (ob *PyObject) SetAttrString(name string, value *C.PyObject) error { |
| 240 | attr := C.CString(name) |
| 241 | defer C.free(unsafe.Pointer(attr)) |
| 242 | err := int(C.PyObject_SetAttrString(ob.rawptr, attr, value)) |
| 243 | if err == -1 { |
| 244 | return fmt.Errorf("couldn't set the value of the %q attribute", name) |
| 245 | } |
| 246 | return nil |
| 247 | } |
| 248 | |
| 249 | // GetAttrString retrieves an attribute named from object the object. Returns an error if the attribute can't be fetched. |
| 250 | func (ob *PyObject) GetAttrString(name string) (*PyObject, error) { |