示例#1
0
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)
}