PythonReference Element Access {RSPython}R Documentation

Syntactic convenience for calling a Python references's method


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


"$.PythonReference"(obj, name)


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.


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.


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


Duncan Temple Lang


See Also

.PythonMethod .Python .PythonNew .PythonEval .PythonEvalFile


## 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]