Modules {XRPython}R Documentation

Import a Python module or add a directory to the Python Search Path

Description

If called from the source directory of a package during installation, both pythonImport and pythonAddToPath() also set up a load action for that package. The functional versions, not the methods themselves, should be called from package source files to ensure that the load actions are created.

Usage

pythonImport(..., evaluator, where = topenv(parent.frame()))

pythonAddToPath(directory = "python",
  package = utils::packageName(topenv(parent.frame())), pos = NA, evaluator,
  where = topenv(parent.frame()))

Arguments

..., where

arguments for the $Import() method. See the method documentation for details.

evaluator

The evaluator object to use. Supplying this argument suppresses the load action.

directory

the directory to add, defaults to "python"

package, pos

arguments package and pos to the method, usually omitted.

Functions

Examples

## Not run: 
## How to search from a local directory, import a function from a file there
## and call the function.
## Including the evaluator argument causes the path change and import to happen
## right now, not in a package being loaded
ev <- RPython()
pythonAddToPath("/Users/me/myPython/", package = "",
                evaluator = ev)
pythonImport("funEx", "foo", evaluator = ev)
pythonCall("foo", 1.1, 1.2)

## End(Not run)

[Package XRPython version 0.8 Index]