Learn R Programming

SnakeCharmR (version 1.0.7.1)

py.rm: Remove a Python variable from R

Description

This function uses the del Python command to remove a variable and reclaim its memory. Any exceptions, such as the one that would happen if the variable did not exist, will be caught and ignored.

Usage

py.rm(var.name, stopOnException = FALSE)

Arguments

var.name

a character string containing a valid Python variable name

stopOnException

if TRUE then stop will be called if a Python exception occurs, typically because the variable doesn't exist, otherwise only a warning will be flagged

Examples

Run this code
# NOT RUN {
py.assign("a", "foo bar")
py.get("a")
# [1] "foo bar"
py.rm("a")
# }
# NOT RUN {
py.rm("a")
# Warning message:
# In py.rm("a") : Traceback (most recent call last):
#   File "<string>", line 2, in <module>
# NameError: name 'a' is not defined
# }

Run the code above in your browser using DataLab