Exemplo n.º 1
0
// Merge merges key values pairs from Object o (which may be a dictionary, or an
// object that supports "o.keys()" and "o[key]") into the dictionary d.  If
// override is true then a matching key in d will have it's value replaced by
// the one in o, else the value in d will be left.
func (d *Dict) Merge(o Object, override bool) error {
	over := 0
	if override {
		over = 1
	}
	ret := C.PyDict_Merge(c(d), c(o), C.int(over))
	return int2Err(ret)
}
Exemplo n.º 2
0
Arquivo: dict.go Projeto: MogeiWang/py
// Merge merges key values pairs from Object o (which may be a dictionary, or an
// object that supports "o.keys()" and "o[key]") into the dictionary d.  If
// override is true then a matching key in d will have it's value replaced by
// the one in o, else the value in d will be left.
func (d *Dict) Merge(o *Base, override bool) error {
	over := 0
	if override {
		over = 1
	}
	ret := C.PyDict_Merge(d.c(), o.c(), C.int(over))
	return int2Err(ret)
}
Exemplo n.º 3
0
// int PyDict_Merge(PyObject *a, PyObject *b, int override)
// Iterate over mapping object b adding key-value pairs to dictionary a. b may be a dictionary, or any object supporting PyMapping_Keys() and PyObject_GetItem(). If override is true, existing pairs in a will be replaced if a matching key is found in b, otherwise pairs will only be added if there is not a matching key in a. Return 0 on success or -1 if an exception was raised.
//
// New in version 2.2.
func PyDict_Merge(a, b *PyObject, override int) error {
	err := C.PyDict_Merge(topy(a), topy(b), C.int(override))
	return int2err(err)
}