func (o *object) ItemValue(t *Thread, i int) (item interface{}, err error) { t.execute(func() { pyItem := C.PySequence_GetItem(o.pyObject, C.Py_ssize_t(i)) if pyItem == nil { err = getError() return } defer C.DECREF(pyItem) item, err = decode(pyItem) }) return }
func (o *object) Item(t *Thread, i int) (item Object, err error) { t.execute(func() { pyItem := C.PySequence_GetItem(o.pyObject, C.Py_ssize_t(i)) if pyItem == nil { err = getError() return } defer C.DECREF(pyItem) item = newObject(pyItem) }) return }
// decodeSequence translates a Python object to a Go array. func decodeSequence(pySequence *C.PyObject) (array []interface{}, err error) { length := int(C.PySequence_Size(pySequence)) array = make([]interface{}, length) for i := 0; i < length; i++ { pyValue := C.PySequence_GetItem(pySequence, C.Py_ssize_t(i)) if pyValue == nil { err = getError() return } var value interface{} if value, err = decode(pyValue); err != nil { return } array[i] = value } return }
func (s *SequenceProtocol) GetItem(i int64) (Object, error) { ret := C.PySequence_GetItem(csp(s), C.Py_ssize_t(i)) return obj2ObjErr(ret) }