Creates a virtual Python list

Description

The function pyList creates a virtual Python object of type PythonInR_List.

Usage

1
pyList(key, value, regFinalizer = TRUE)

Arguments

key

a character string giving the name of the Python object.

value

an optional value, allowed values are vectors, lists and NULL.

regFinalizer

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

Details

If no value is provided a virtual Python list for an existing Python object is created. If the value is NULL an empty virtual Python object for an empty list is created. If the value is a vector or a list, a new Python object based on the vector or list is created.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
if ( pyIsConnected() ){
pyExec('myPyList = [1, 2, 5, "Hello R!"]')
# create a virtual Python list for an existing list
myList <- pyList("myPyList")
myList[0]
myList[1] <- "changed"
myList
# create a new Python list and virtual list
myNewList <- pyList('myNewList', list(1:3, 'Hello Python'))
myNewList[1]
myNewList$append(4L)
ls(myNewList)
## NOTE: Indexing which can not be interpreted as correct R
##       syntax should be provided as a character string.
myNewList['::2'] 
}

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.