py.attr: Get/set Python object attributes.

Description Usage Arguments Author(s) Examples

Description

py.attr retrieves the attribute of a Python object.

`$` is a syntactic sugar for retrieving an attribute and `$<-` for setting it.

Usage

1
2
3
py.attr(x, name, .ref = FALSE)
`$.pyref`(x, name)
`$<-.pyref`(x, name, value)

Arguments

x

Python reference object

name

name of the attribute

value

new value

.ref

logical, if TRUE a reference to the Python object is returned, otherwise a conversion to R native type is attempted

Author(s)

Simon Urbanek

Examples

1
2
3
4
5
6
7
8
py.init()
main = py.import("__main__")
main$x = 1:10
py.eval("y = len(x)")
main$y
len = py.get("len", "__builtin__", .ref=TRUE)
len
len$`__call__`

s-u/rpython documentation built on May 28, 2019, 10:48 a.m.