MissingPy-0.10.5: Haskell interface to Python

MaintainerJohn Goerzen,

Python.Interpreter

Contents

Description

Maintainer : jgoerzen@complete.org Stability : provisional Portability: portable

Interface to Python interpreter

Written by John Goerzen, jgoerzen@complete.org

Synopsis

Documentation

py_initialize :: IO ()Source

Initialize the Python interpreter environment.

MUST BE DONE BEFORE DOING ANYTHING ELSE!

Intrepreting Code

pyRun_StringSource

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.

pyRun_StringHsSource

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.

data StartFrom Source

How to interpret a snippet of Python code.

Calling Code

callByNameSource

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.

callByNameHsSource

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 

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.

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

withGIL :: IO a -> IO aSource