INNER CODE UNIT · Python
local_context
rpy2/rpy2 · rpy2-rinterface/src/rpy2/rinterface/__init__.py:84
def local_context(
env: typing.Optional[SexpEnvironment] = None,
use_rlock: bool = True
) -> typing.Iterator[SexpEnvironment]:
"""Local context for the evaluation of R code.
Args:
- env: an environment to use as a context. If not specified (None, the
default), a child environment to the current context is created.
- use_rlock: whether to use a threading lock (see the documentation about
"rlock". The default is True.
Returns:
Yield the environment (passed to env, or created).
"""
parent_frame = evaluation_context.get()
if env is None: