package pyml

  1. Overview
  2. Docs

Interface for Python values of type Callable.

val check : Object.t -> bool

check v returns true if v is callable. Wrapper for PyCallable_Check.

val handle_errors : ('a -> Object.t) -> 'a -> Object.t

handle_errors f x calls f x and returns its result if the call succeeds. If f x raises a Python exception (Py.E (errtype, errvalue) or Py.Err (errtype, msg)), this exception is raised as a Python exception (via Err.set_object or Err.set_error respectively).

val of_function_as_tuple : ?name:string -> ?docstring:string -> (Object.t -> Object.t) -> Object.t

of_function_as_tuple f returns a Python callable object that calls the function f. Arguments are passed as a tuple. If f raises a Python exception (Py.E (errtype, errvalue) or Py.Err (errtype, msg)), this exception is raised as a Python exception (via Err.set_object or Err.set_error respectively). If f raises any other exception, this exception bypasses the Python interpreter.

val of_function_as_tuple_and_dict : ?name:string -> ?docstring:string -> (Object.t -> Object.t -> Object.t) -> Object.t

of_function_as_tuple_and_dict f returns a Python callable object that calls the function f. Arguments are passed as a tuple and a dictionary of keywords.

val of_function : ?name:string -> ?docstring:string -> (Object.t array -> Object.t) -> Object.t

Equivalent to of_function_as_tuple but with an array of Python objects instead of a tuple for passing arguments.

val of_function_with_keywords : ?name:string -> ?docstring:string -> (Object.t array -> Object.t -> Object.t) -> Object.t

Equivalent to of_function_as_tuple_and_dict but with an array of Python objects instead of a tuple for passing arguments. The dictionary of keywords is passed as such as it is more efficient to access arguments with ``Py.Dict.find_string``, rather than using ``List.assoc`` with an associative list.

val to_function_as_tuple : Object.t -> Object.t -> Object.t

to_function_as_tuple c returns a function f such that f args calls the Python callable c with the Python tuple args as arguments.

val to_function_as_tuple_and_dict : Object.t -> Object.t -> Object.t -> Object.t

to_function_as_tuple_and_dict c returns a function f such that f args dict calls the Python callable c with the Python tuple args and the dictionary of keywords dict as arguments.

val to_function : Object.t -> Object.t array -> Object.t

Equivalent to to_function_as_tuple but with an array of Python objects instead of a tuple for passing arguments.

val to_function_with_keywords : Object.t -> Object.t array -> (string * Object.t) list -> Object.t

Equivalent to to_function_as_tuple_and_dict but with an array of Python objects instead of a tuple and an associative list instead of a dictionary for passing arguments.