BEGIN.Python: Execute Python interactively from within R

Description Usage Details Value Examples

View source: R/PySource.R

Description

The function BEGIN.Python starts an Python read-eval-print loop.

Usage

1

Details

BEGIN.Python emulates the behavior of the Python terminal and therefore allows interactive Python code development from within R.

Value

Returns the entered code as character, code lines which throw an exception are omitted.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
code <-
BEGIN.Python()
import os
os.getcwd()
dir(os)
x = 3**3
for i in xrange(10):
    if (i > 5):
        print(i)

END.Python
## NOTE: BEGIN.Python returns the successfully executed code as character.
cat(code, sep="\n")
pyGet0("x")

## End(Not run)

PythonInR documentation built on July 1, 2020, 6:05 p.m.