示例#1
0
文件: python.go 项目: gbbr/textmate
func AddToPath(dir string) {
	p := C.CString("path")
	defer C.free(unsafe.Pointer(p))

	sys_path := C.PySys_GetObject(p)
	if sys_path == nil {
		return
	}

	s := C.CString(dir)
	defer C.free(unsafe.Pointer(s))

	pDir := C.PyUnicode_FromString(s)
	if pDir == nil {
		return
	}

	C.PyList_Append(sys_path, pDir)
}
示例#2
0
// int PyList_Append(PyObject *list, PyObject *item)
// Append the object item at the end of list list. Return 0 if successful; return -1 and set an exception if unsuccessful. Analogous to list.append(item).
// PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
// Return value: New reference.
// Return a list of the objects in list containing the objects between low and high. Return NULL and set an exception if unsuccessful. Analogous to list[low:high]. Negative indices, as when slicing from Python, are not supported.
//
// Changed in version 2.5: This function used an int for low and high. This might require changes in your code for properly supporting 64-bit systems.
func PyList_Append(self, item *PyObject) error {
	err := C.PyList_Append(topy(self), topy(item))
	return int2err(err)
}
示例#3
0
// Append adds the Object obj to list l, by appending it to the end of the list.
// This is equivalent to the Python "l.append(obj)"
func (l *List) Append(obj Object) error {
	ret := C.PyList_Append(c(l), c(obj))
	return int2Err(ret)
}