Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Importing Modules
val add_module : string -> Object.t
Wrapper for PyImport_AddModule
exec_code_module name bytecode
imports the module name
compiled in bytecode
. bytecode
can be obtained with Py.compile
. Wrapper for PyImport_ExecCodeModule
Wrapper for PyImport_ExecCodeModuleEx
Wrapper for PyImport_GetMagicNumber
val get_module_dict : unit -> Object.t
Wrapper for PyImport_GetModuleDict
Wrapper for PyImport_ImportFrozenModule
val import_module : string -> Object.t
Wrapper for PyImport_ImportModule Note that Python memoizes imported module, so that you will get the same object if you import the same module twice. (GitHub issue #16)
let m = Py.Import.import_module "json"
and m' = Py.Import.import_module "json" in
assert (m = m')
val import_module_opt : string -> Object.t option
import_module_opt m
imports the module m
and returns the module object if the import succeeds:. in this case, it is equivalent to Some (import_module m)
. If the module is not found, i.e. if import_module
raises a Python exception of class ModuleNotFoundError
, then try_import_module
returns None
.
val try_import_module : string -> Object.t option
Alias for import_module_opt
.
Wrapper for PyImport_ImportModuleEx
Wrapper for PyImport_ImportModuleLevel
Wrapper for PyImport_ReloadModule