pyGet
=====
The function pyGet gets Python objects by name and transforms
them into R objects.
Since any Python object can be transformed into one of the basic
data types it is up to the user to do so up front. More information
about the type conversion can be found in the README file or at
``_.
.. note::
pyGet always returns a new object, if you want to create a R representation
of an existing Python object use pyGet0 instead.
Usage
-----
.. code-block:: R
pyGet(key, autoTypecast = TRUE, simplify = TRUE)
Arguments
---------
.. raw:: html
key |
a string specifying the name of a Python object. |
autoTypecast |
an optional logical value, default is TRUE, specifying
if the return values should be automatically typecasted if possible. |
simplify |
an optional logical value, if TRUE R converts Python lists
into R vectors whenever possible, else it translates Python lists
always into R lists. |
Examples
--------
.. code-block:: R
## get a character of length 1
pyGet("__name__")
## get a character of length 1 > 1
pyGet("sys.path")
## get a list
pyGet("sys.path", simplify = FALSE)
## get a PythonInR_List
x <- pyGet("sys.path", autoTypecast = FALSE)
x
class(x)
## get an object where no specific transformation to R is defined
## this example also shows the differnces between pyGet and pyGet0
pyExec("import datetime")
## pyGet creates a new Python variable where the return value of pyGet is
## stored the name of the new reference is stored in x$py.variableName.
x <- pyGet("datetime.datetime.now().time()")
x
class(x)
x$py.variableName
## pyGet0 never creates a new Python object, objects which can be transformed
## to R objects are transformed. For all other objects an PythonInR_Object is created.
y <- pyGet0("datetime.datetime.now().time()")
y
## An important difference is that the evaluation of x always will return the same
## time, the evaluation of y always will give the new time.