Skip to contents

Get 'Python' built-in object

Usage

py_builtin(name, convert = FALSE)

Arguments

name

object name

convert

see import_builtins

Value

A python built-in object specified by name

Examples


if(interactive() && dir.exists(env_path())) {


# ------ Basic case: use python `int` as an R function ---------
py_int <- py_builtin("int", convert = TRUE)

# a is an R object now
a <- py_int(9)
print(a)
class(a)

# ------ Use python `int` as a Python function -----------------
py_int2 <- py_builtin("int", convert = FALSE)

# b in a python object
b <- py_int2(9)

# There is no '[1] ' when printing
print(b)
class(b)

# convert to R object
py_to_r(b)



}