setPythonClass: Create a Proxy Class for a Python Class

Description Usage Arguments Details

View source: R/classStructure.R


An R class is defined to act as a proxy for a specified Python class. This specializes the setProxyClass function using Python facilities for finding the class definition.


setPythonClass(Class, module = "", fields = character(), methods = NULL,
  ServerClass = Class, where = topenv(parent.frame()),
  contains = character(), proxyObjectClass = "PythonObject", ...,
  example = TRUE)



the Python name for the class.


the Python module, if this is not a standard library class.

fields, methods, where, ...

arguments to setProxyClass and usually omitted.

ServerClass, contains, proxyObjectClass



an optional (proxy for) an object from the class, to be used to define the fields in the class. If omitted, the interface tries to create a standard object from the class by calling the Python generator with no argument. Argument example can also be supplied as FALSE to suppress generating the default object.


The methods and (inferred) fields of a Python Class are determined and returned consistently with the XR structure. Python classes are coded as class objects in Python, but only the methods are fixed and defined. Objects from the class can have any fields, usually created at initialization time but entirely legal to be added by other methods later. By default, the initialize method tries to create an object from the class, with no arguments in the call to the class generator. Supply the example argument to override.

XRPython documentation built on Nov. 17, 2017, 7:09 a.m.