.PythonEvalFile {RSPython}R Documentation

Evaluate a Python script from a string or file.

Description

These two functions allow one to evaluate Python scripts which are given in the Python syntax. These can be specified as a string or as a file containing the Python code. This approach to evaluating Python commands is less flexible than those offered by .Python and related functions.

Usage

.PythonEvalFile(cmd, ..., .module=NULL, .convert=T)
.PythonEval(cmd, ..., .module=NULL, .convert=T, .isFile = FALSE)

Arguments

cmd the Python expression to parse and evaluate.
... Any number of name-value pairs that are converted to a Python dictionary or context which will be used when evaluating the expression.
.module the name of the module whose dictionary is used to provide the name space for resolving symbols in the Python expressions.
.convert a logical value indicating whether the result of evaluating the Python object should be converted to a regular R object, if possible, or explicitly left within Python and returned as a PythonReference object.
.isFile indicates whether the command `cmd' identifies a file by name whose contents should be evaluated, or is a Python expression.

Details

Value

The value returned from evaluating the Python expression(s), converted to R using the standard conversion mechanism, including any user-level converters currently registered.

Author(s)

Duncan Temple Lang

References

http://www.omegahat.org/RSPython, http://www.python.org

See Also

.Python .PythonMethod .PythonNew

Examples

.PythonEval("import sys; sys.version")

  #
# .PythonEval("from sys import *")
 .PythonEval("sys.version")

[Package RSPython Index]