pyObject: Creates a virtual Python object

View source: R/PyObject.R

pyObjectR Documentation

Creates a virtual Python object

Description

The function pyObject creates a virtual Python object of type PythonInR_Object.

Usage

pyObject(key, regFinalizer = TRUE)

Arguments

key

a character string giving the name of the Python object.

regFinalizer

a logical indicating if a finalizer should be be registered, the default value is TRUE.

Details

Every PythonInR_Object has the following members:

  • py.variableName the variable name used in Python.

  • py.objectName the name of the Python object (obtained by x.__name__) or NULL.

  • py.type the type of the Python object.

  • py.del a function to delete the Python object.

  • print for more information see R6 classes.

  • initialize for more information see R6 classes.

The other members of PythonInR_Object's are generated dynamically based on the provided Python object. The R function ls can be used to view the members of a PythonInR_Object object.

Examples


if ( pyIsConnected() ){
pyExec("import os")
os <- pyObject("os", regFinalizer = FALSE)
ls(os)
## To show again the difference between pyGet and pyGet0.
os1 <- pyGet0("os") ## has no finalizer
os2 <- pyGet("os")  ## has a finalizer
os$py.variableName
os1$py.variableName
os2$py.variableName
}

Sage-Bionetworks/PythonEmbedInR documentation built on April 17, 2023, 4:23 p.m.