Exemplo n.º 1
0
func Import(name string) (*Module, error) {
	s := C.CString(name)
	defer C.free(unsafe.Pointer(s))

	pyName := C.PyString_FromString(s)
	defer C.decref(pyName)

	obj := C.PyImport_Import(pyName)
	if obj == nil {
		return nil, exception()
	}

	return newModule(obj), nil
}
Exemplo n.º 2
0
// PyObject* PyImport_Import(PyObject *name)
// Return value: New reference.
// This is a higher-level interface that calls the current “import hook function”. It invokes the __import__() function from the __builtins__ of the current globals. This means that the import is done using whatever import hooks are installed in the current environment, e.g. by rexec or ihooks.
//
// Changed in version 2.6: Always uses absolute imports.
func PyImport_Import(name *PyObject) *PyObject {
	return togo(C.PyImport_Import(topy(name)))
}
Exemplo n.º 3
0
func Import(name *PyObject) *PyObject {
	return PyObjectToGO(C.PyImport_Import(GoToPyObject(name)))
}