Example #1
0
// MergeFromSeq2 merges key values pairs from the Object o (which must be an
// iterable object, where each item is an iterable of length 2 - the key value
// pairs).  If override is true then the last key value pair with the same key
// wins, otherwise the first instance does (where an instance already in d
// counts before any in o).
func (d *Dict) MergeFromSeq2(o Object, override bool) error {
	over := 0
	if override {
		over = 1
	}
	ret := C.PyDict_MergeFromSeq2(c(d), c(o), C.int(over))
	return int2Err(ret)
}
Example #2
0
File: dict.go Project: MogeiWang/py
// MergeFromSeq2 merges key values pairs from the Object o (which must be an
// iterable object, where each item is an iterable of length 2 - the key value
// pairs).  If override is true then the last key value pair with the same key
// wins, otherwise the first instance does (where an instance already in d
// counts before any in o).
func (d *Dict) MergeFromSeq2(o *Base, override bool) error {
	over := 0
	if override {
		over = 1
	}
	ret := C.PyDict_MergeFromSeq2(d.c(), o.c(), C.int(over))
	return int2Err(ret)
}
Example #3
0
// int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override)
// Update or merge into dictionary a, from the key-value pairs in seq2. seq2 must be an iterable object producing iterable objects of length 2, viewed as key-value pairs. In case of duplicate keys, the last wins if override is true, else the first wins. Return 0 on success or -1 if an exception was raised. Equivalent Python (except for the return value):
//
// def PyDict_MergeFromSeq2(a, seq2, override):
//     for key, value in seq2:
//         if override or key not in a:
//             a[key] = value
// New in version 2.2.
func PyDict_MergeFromSeq2(a, seq2 *PyObject, override int) error {
	err := C.PyDict_MergeFromSeq2(topy(a), topy(seq2), C.int(override))
	return int2err(err)
}