package pyml

  1. Overview
  2. Docs

Module Py.ModuleSource

Interface for Python values of type Module.

Sourceval check : Object.t -> bool

check o returns true if o is a Python module.

Sourceval create : string -> Object.t

Wrapper for PyModule_New

Sourceval get_dict : Object.t -> Object.t

Wrapper for PyModule_GetDict

Sourceval get_filename : Object.t -> string
Sourceval get_name : Object.t -> string

Wrapper for PyModule_GetName

Sourceval get : Object.t -> string -> Object.t
Sourceval get_opt : Object.t -> string -> Object.t option
Sourceval get_function : Object.t -> string -> Object.t array -> Object.t

Py.Module.get_function m name is equivalent to Py.Callable.to_function (Py.Module.get m name).

Sourceval get_function_opt : Object.t -> string -> (Object.t array -> Object.t) option

Py.Module.get_function_opt is equivalent to Py.Module.get_function but returns None in case of failure.

Sourceval get_function_with_keywords : Object.t -> string -> Object.t array -> (string * Object.t) list -> Object.t

Py.Module.get_function_with_keywords m name is equivalent to Py.Callable.to_function_with_keywords (Py.Module.get m name).

Sourceval get_function_with_keywords_opt : Object.t -> string -> (Object.t array -> (string * Object.t) list -> Object.t) option

Py.Module.get_function_with_keywords_opt is equivalent to Py.Module.get_function_with_keywords but returns None in case of failure.

Sourceval set : Object.t -> string -> Object.t -> unit

Equivalent to Object.set_attr_string.

Sourceval set_function : Object.t -> string -> (Object.t array -> Object.t) -> unit

Py.Module.set_function m name f is equivalent to Py.Module.set m name (Py.Callable.of_function f).

Sourceval set_function_with_keywords : Object.t -> string -> (Object.t array -> Object.t -> Object.t) -> unit

Py.Module.set_function_with_keywords m name f is equivalent to Py.Module.set m name (Py.Callable.of_function_with_keywords f).

Sourceval remove : Object.t -> string -> unit

Equivalent to Object.del_attr_string.

Sourceval main : unit -> Object.t

Returns the __main__ module. We have Py.Module.main () = Py.Module.add_module "__main__".

Sourceval sys : unit -> Object.t

Returns the sys module. We have Py.Module.sys () = Py.Module.import_module "sys".

Sourceval builtins : unit -> Object.t

Returns the __builtins__ module. We have Py.Module.builtins () = Py.Module.find (Py.Module.main ()) "__builtins__".

Sourceval set_docstring : Object.t -> string -> unit
Sourceval compile : source:string -> filename:string -> ?dont_inherit:bool -> ?optimize:optimize -> input -> Object.t

compile ~source ~filename ?dont_inherit ?optimize mode returns the bytecode obtained by compiling ~source. It is a wrapper for the built-in function compile(). GitHub issue #25

OCaml

Innovation. Community. Security.