.Python {RSPython}R Documentation

Invoke a Python function or instance method

Description

These are the functions that invoke a Python function or a method of a Python object. They transfer the S arguments to their corresponding Python values and invoke the identified function object. The resulting Python value is transferred back as an S object using the default converters.

Usage

.Python(func, ..., .module=NULL, .convert=T)
.PythonMethod(ref, method, ..., .convert=T)

Arguments

func usually, a string specifying the name of the Python function to invoke. This can also be a PythonReference object which refers to a previously ``computed'' function object.
ref The Python object whose instance method is to be invoked. This is the self object in Python terms.
method the name of the instance method to be invoked.
... the arguments to the Python function or method, given as S objects and converted to Python using the default converters.
.module the name of the module in which to find to find and resolve the Python function
.convert a logical value indicating whether an attempt to convert the result from the Python function or method to a regular R value should be made, or whether the object should be left on the Python side of the interface and a reference to it returned. Avoiding conversion can be useful when the value will be used in subsequent calls Python functions or methods.

Details

These functions use the standard conversion mechanism for translating R objects to Python values and vice versa. These can be augmented by

Value

The return value resulting from calling the Python function or method. This is converted to an R object or returned as a reference to the Python object in the form of an object PythonReference.

Author(s)

Duncan Temple Lang

References

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

See Also

.PythonEval .PythonEvalFile .Perl .Java .CORBA

Examples

 .Python("version", .module="sys")
 .Python("path", .module="sys")

[Package RSPython Index]