| Maintainer | John Goerzen, |
|---|
Python.Interpreter
Contents
Description
Maintainer : [email protected] Stability : provisional Portability: portable
Interface to Python interpreter
Written by John Goerzen, [email protected]
- py_initialize :: IO ()
- pyRun_SimpleString :: String -> IO ()
- pyRun_String :: String -> StartFrom -> [(String, PyObject)] -> IO PyObject
- pyRun_StringHs :: (ToPyObject b, FromPyObject c) => String -> StartFrom -> [(String, b)] -> IO c
- data StartFrom
- callByName :: String -> [PyObject] -> [(String, PyObject)] -> IO PyObject
- callByNameHs :: (ToPyObject a, ToPyObject b, FromPyObject c) => String -> [a] -> [(String, b)] -> IO c
- noParms :: [String]
- noKwParms :: [(String, String)]
- pyImport :: String -> IO ()
- pyImport_ImportModule :: String -> IO PyObject
- pyImport_AddModule :: String -> IO PyObject
- pyModule_GetDict :: PyObject -> IO PyObject
- py_initializeThreaded :: IO ()
- cpy_GILEnsure :: IO (Ptr CPyGILState)
- cpy_GILRelease :: Ptr CPyGILState -> IO ()
- withGIL :: IO a -> IO a
Documentation
Initialize the Python interpreter environment.
MUST BE DONE BEFORE DOING ANYTHING ELSE!
Intrepreting Code
pyRun_SimpleString :: String -> IO ()Source
Arguments
| :: String | Command to run |
| -> StartFrom | Start Token -> [(String, PyObject)] -- ^ Globals (may be empty) |
| -> [(String, PyObject)] | Locals (may be empty) |
| -> IO PyObject | Result |
Run some code in Python.
Arguments
| :: (ToPyObject b, FromPyObject c) | |
| => String | Command to run |
| -> StartFrom | Start token -> [(String, a)] -- ^ Globals (may be empty) |
| -> [(String, b)] | Locals (may be empty) |
| -> IO c |
Like pyRun_String, but take more Haskellish args and results.
How to interpret a snippet of Python code.
Constructors
| Py_eval_input | |
| Py_file_input | |
| Py_single_input |
Calling Code
Arguments
| :: String | Object/function name |
| -> [PyObject] | List of non-keyword parameters |
| -> [(String, PyObject)] | List of keyword parameters |
| -> IO PyObject |
Call a function or callable object by name.
Arguments
| :: (ToPyObject a, ToPyObject b, FromPyObject c) | |
| => String | Object/function name |
| -> [a] | List of non-keyword parameters |
| -> [(String, b)] | List of keyword parameters |
| -> IO c |
Imports
pyImport :: String -> IO ()Source
Import a module into the current environment in the normal sense (similar to "import" in Python).
pyImport_ImportModule :: String -> IO PyObjectSource
Wrapper around C PyImport_ImportModule, which imports a module.
You may want the higher-level pyImport instead.
pyImport_AddModule :: String -> IO PyObjectSource
Wrapper around C PyImport_AddModule, which looks up an existing module
pyModule_GetDict :: PyObject -> IO PyObjectSource
Gets the dict associated with a module.
Threads
cpy_GILRelease :: Ptr CPyGILState -> IO ()Source