PythonReference Element Access {RSPython}R Documentation

Syntactic convenience for calling a Python references's method

Description

This allows one to call a method of a Python object from R in a simple form such as pyObj$method(arg1, arg2, ...). This provides an overloading of the $ operator for R objects of class PythonReference to return a simplified call to .PythonMethod

Usage

"$.PythonReference"(obj, name)

Arguments

obj the PythonReference object whose method is to be called.
name the name of the method in the Python object which is to be called.

Details

When calling a Python object's method from R, one specifies the reference to the Python object and the name of the method along with the arguments to that method in a call to .PythonMethod. This function/method returns function object containing sufficient information to call the specified method on the given reference. These two pieces of information are stored in an R closure instance and this can then be called as a regular function whose body calls .PythonMethod.

Value

A function closure instance whose body consists of a call to .PythonMethod for the specified PythonReference object and method name.

Author(s)

Duncan Temple Lang

References

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

See Also

.PythonMethod .Python .PythonNew .PythonEval .PythonEvalFile

Examples

## Not run: 
 x <- .PythonNew("ArithmeticError", "Some error message", .module="exceptions") 
 x$"__str__"()  # call the __str__() method, escaping the __ 
 x$args()       # 
## End(Not run)

[Package RSPython Index]