Example #1
0
// PyObject* PyFunction_New(PyObject *code, PyObject *globals)
// Return value: New reference.
// Return a new function object associated with the code object code. globals must be a dictionary with the global variables accessible to the function.
//
// The function’s docstring, name and __module__ are retrieved from the code object, the argument defaults and closure are set to NULL.
func PyFunction_New(code, globals *PyObject) *PyObject {
	return togo(C.PyFunction_New(topy(code), topy(globals)))
}
Example #2
0
// NewFunction returns a new Function object that is associated with the given
// "code" and "globals".  "globals" must be a dictionary, and it should hold the
// global variables for the function.
//
// The function inherits its docstring, name and __module__ from the "code"
// object, the argument defaults and closure are initialised to nil.
//
// Return value: New Reference.
func NewFunction(code Object, globals Object) (*Function, error) {
	ret := C.PyFunction_New(c(code), c(globals))
	return newFunction(ret), nil
}