Esempio n. 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
}
Esempio n. 2
0
// 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)
}
Esempio n. 3
0
// 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)))
}
Esempio n. 4
0
File: dict.go Progetto: 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)
}