Learn R Programming

reticulate (version 1.38.0)

py_repr: String representation of a python object.

Description

This is equivalent to calling str(object) or repr(object) in Python.

Usage

py_repr(object)

py_str(object, ...)

Value

Character vector

Arguments

object

Python object

...

Unused

Details

In Python, calling print() invokes the builtin str(), while auto-printing an object at the REPL invokes the builtin repr().

In R, the default print method for python objects invokes py_repr(), and the default format() and as.character() methods invoke py_str().

For historical reasons, py_str() is also an R S3 method that allows R authors to customize the the string representation of a Python object from R. New code is recommended to provide a format() and/or print() S3 R method for python objects instead.

The default implementation will call PyObject_Str on the object.