Create a Proxy Class for a Python Class

Description

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.

Usage

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

Arguments

Class

the Python name for the class.

module

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

fields,methods,where,...

arguments to setProxyClass and usually omitted.

ServerClass,contains,proxyObjectClass

ditto.

example

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.

Details

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.