예제 #1
0
파일: python.go 프로젝트: tsavola/go-python
func (o *object) GetValue(t *Thread, key interface{}) (value interface{}, found bool, err error) {
	t.execute(func() {
		var pyKey *C.PyObject

		if pyKey, err = encode(key); err != nil {
			return
		}
		defer C.DECREF(pyKey)

		pyValue := C.PyDict_GetItem(o.pyObject, pyKey)
		if pyValue == nil {
			return
		}

		value, err = decode(pyValue)
		found = (err == nil)
	})
	return
}
예제 #2
0
파일: dict.go 프로젝트: gbbr/textmate
// GetItem returns the Object from dictionary d which has the key "key".  If
// there is no such Object, then nil is returned (without an error).
//
// Return value: Borrowed Reference.
func (d *Dict) GetItem(key Object) (Object, error) {
	ret := C.PyDict_GetItem(c(d), c(key))
	return obj2ObjErr(ret)
}
예제 #3
0
파일: dict.go 프로젝트: remh/go-python
// PyObject* PyDict_GetItem(PyObject *p, PyObject *key)
// Return value: Borrowed reference.
// Return the object from dictionary p which has a key key. Return NULL if the key key is not present, but without setting an exception.
func PyDict_GetItem(self, key *PyObject) *PyObject {
	return togo(C.PyDict_GetItem(topy(self), topy(key)))
}
예제 #4
0
파일: dict.go 프로젝트: MogeiWang/py
// GetItem returns the Object from dictionary d which has the key "key".  If
// there is no such Object, then nil is returned (without an error).
//
// Return value: Borrowed Reference.
func (d *Dict) GetItem(key *Base) *Base {
	ret := C.PyDict_GetItem(d.c(), key.c())
	return newObject(ret)
}