cpython-3.9.0: Bindings for libpython
Safe HaskellSafe-Inferred
LanguageHaskell2010

CPython.Types.Module

Synopsis

Documentation

data Module Source #

Instances

Instances details
Concrete Module Source # 
Instance details

Defined in CPython.Types.Module

Methods

concreteType :: Module -> Type

Object Module Source # 
Instance details

Defined in CPython.Types.Module

moduleType :: Type Source #

Return a new module object with the name attribute set. Only the module’s doc and name attributes are filled in; the caller is responsible for providing a file attribute.

getDictionary :: Module -> IO Dictionary Source #

Return the dictionary object that implements a module’s namespace; this object is the same as the dict attribute of the module. This computation never fails. It is recommended extensions use other computations rather than directly manipulate a module’s dict.

getName :: Module -> IO Text Source #

Returns a module’s name value. If the module does not provide one, or if it is not a string, throws SystemError.

getFilename :: Module -> IO Text Source #

Returns the name of the file from which a module was loaded using the module’s file attribute. If this is not defined, or if it is not a string, throws SystemError.

addObject :: Object value => Module -> Text -> value -> IO () Source #

Add an object to a module with the given name. This is a convenience computation which can be used from the module’s initialization computation.

addIntegerConstant :: Module -> Text -> Integer -> IO () Source #

Add an integer constant to a module. This convenience computation can be used from the module’s initialization computation.

addTextConstant :: Module -> Text -> Text -> IO () Source #

Add a string constant to a module. This convenience computation can be used from the module’s initialization computation.

importModule :: Text -> IO Module Source #

This is a higher-level interface that calls the current “import hook” (with an explicit level of 0, meaning absolute import). It invokes the import() computation from the builtins of the current globals. This means that the import is done using whatever import hooks are installed in the current environment.

This computation always uses absolute imports.

reload :: Module -> IO Module Source #

Reload a module. If an error occurs, an exception is thrown and the old module still exists.