ContentsIndex
Python.Interpreter
Portability portable
Stability provisional
Maintainer jgoerzen@complete.org
Contents
Intrepreting Code
Calling Code
Imports
Description

Interface to Python interpreter

Written by John Goerzen, jgoerzen@complete.org

Synopsis
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
= Py_eval_input
| Py_file_input
| Py_single_input
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
Documentation
py_initialize :: IO ()

Initialize the Python interpreter environment.

MUST BE DONE BEFORE DOING ANYTHING ELSE!

Intrepreting Code
pyRun_SimpleString :: String -> IO ()
pyRun_String
:: StringCommand to run
-> StartFromStart Token -> [(String, PyObject)] -- ^ Globals (may be empty)
-> [(String, PyObject)]Locals (may be empty)
-> IO PyObjectResult
Run some code in Python.
pyRun_StringHs
:: (ToPyObject b, FromPyObject c)
=> StringCommand to run
-> StartFromStart 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.
data StartFrom
How to interpret a snippet of Python code.
Constructors
Py_eval_input
Py_file_input
Py_single_input
Calling Code
callByName
:: StringObject/function name
-> [PyObject]List of non-keyword parameters
-> [(String, PyObject)]List of keyword parameters
-> IO PyObject
Call a function or callable object by name.
callByNameHs
:: (ToPyObject a, ToPyObject b, FromPyObject c)
=> StringObject/function name
-> [a]List of non-keyword parameters
-> [(String, b)]List of keyword parameters
-> IO c

Call a function or callable object by namem using Haskell args and return values..

You can use noParms and noKwParms if you have no simple or keyword parameters to pass, respectively.

noParms :: [String]
noKwParms :: [(String, String)]
Imports
pyImport :: String -> IO ()
Import a module into the current environment in the normal sense (similar to "import" in Python).
pyImport_ImportModule :: String -> IO PyObject

Wrapper around C PyImport_ImportModule, which imports a module.

You may want the higher-level pyImport instead.

pyImport_AddModule :: String -> IO PyObject
Wrapper around C PyImport_AddModule, which looks up an existing module
pyModule_GetDict :: PyObject -> IO PyObject
Gets the dict associated with a module.
Produced by Haddock version 0.6