Modules: Import a Python module or add a directory to the Python...

Description Usage Arguments Functions Examples

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

1
2
3
4
5
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

XRPython documentation built on May 2, 2019, 9:33 a.m.