repl_python: Run a Python REPL

Description Usage Arguments Details See Also Examples

View source: R/repl.R

Description

This function provides a Python REPL in the R session, which can be used to interactively run Python code. All code executed within the REPL is run within the Python main module, and any generated Python objects will persist in the Python session after the REPL is detached.

Usage

1
2
repl_python(module = NULL, quiet = getOption("reticulate.repl.quiet",
  default = FALSE))

Arguments

module

An (optional) Python module to be imported before the REPL is launched.

quiet

Boolean; print a startup banner when launching the REPL? If TRUE, the banner will be suppressed.

Details

When working with R and Python scripts interactively, one can activate the Python REPL with repl_python(), run Python code, and later run exit to return to the R console.

See Also

py, for accessing objects created using the Python REPL.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 

# enter the Python REPL, create a dictionary, and exit
repl_python()
dictionary = {'alpha': 1, 'beta': 2}
exit

# access the created dictionary from R
py$dictionary
# $alpha
# [1] 1
#
# $beta
# [1] 2


## End(Not run)

Mormukut11/R-interface-to-Python documentation built on May 21, 2019, 9:36 a.m.