GetAttrString retrieves an attribute named from object the object. Returns an error if the attribute can't be fetched.
(name string)
| 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) { |
| 251 | attr := C.CString(name) |
| 252 | defer C.free(unsafe.Pointer(attr)) |
| 253 | v := C.PyObject_GetAttrString(ob.rawptr, attr) |
| 254 | if v == nil { |
| 255 | return nil, fmt.Errorf("couldn't get the %q attribute", name) |
| 256 | } |
| 257 | return &PyObject{rawptr: v}, nil |
| 258 | } |
| 259 | |
| 260 | // HasAttr determines if the Python object has the specified attribute. |
| 261 | func (ob *PyObject) HasAttr(name string) bool { |
no outgoing calls