Description Usage Arguments Methods Examples
The Python Environment Class. Provides an interface to a Python process.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
port
The port to use for communication with Python.
path
The path to the Python executable.
varname
The name of a Python variable to bring into R.
...
Commands to run or named variables to set in the Python process.
file
File containing Python code to execute.
force
If TRUE
, force the Python process to terminate
using a system call.
$new()
Initialize a Python interface. The Python process is not
started automatically.
$path
Set or get the path to the Python executable. The path
cannot be changed while the Python process is running.
$host
Set or get the host address of the Python connection.
Default is 'localhost'
. The host cannot be changed while the
Python process is running.
$port
Set or get the port of the Python interface. The port
cannot be changed while the Python process is running.
$timeout
Set or get the timeout for receiving messages from
Python. Default is 60 seconds.
$start()
Start the Python process. The Python process runs
asynchronously.
$running
Check if the Python process is running.
$pid
Get the Process ID of the Python interface. Useful for
diagnosing problems.
$set()
Set variables in the Python process. R variables
are encoded into JSON format, sent to the Python process as text,
and decoded into variables on the Python side.
$get()
Get a variable from the Python process. Python
variables are encoded into JSON format, sent to R as text,
and decoded into variables on the R side.
$exec()
Execute the specified Python
commands and invisibly return printed Python output (if any).
Alternatively, the file
argument can be used to specify
a file containing Python code. Note that there will be no return
value unless an explicit Python print
statement is executed.
$stop()
Stop the Python process by sending a request to the
Python process. If force = TRUE
, the process will be
terminated using a system call instead.
print(py)
Show some information about the
Python process on the screen, whether it is running and its process id,
etc.
1 2 3 4 5 6 7 8 9 10 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.