BEGIN.Python: Execute Python interactively from within R

View source: R/PySource.R

BEGIN.PythonR Documentation

Execute Python interactively from within R

Description

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

Usage

BEGIN.Python()

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.

Note

This won't work with RStudio because of a known RStudio issue.

Examples


## 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)

Sage-Bionetworks/PythonEmbedInR documentation built on April 17, 2023, 4:23 p.m.