py_str: String representation of a python object.

View source: R/python.R

py_reprR Documentation

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, ...)

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.

Value

Character vector

See Also

as.character.python.builtin.str() as.character.python.builtin.bytes() for handling ⁠Error : Embedded NUL in string.⁠ if the Python string contains an embedded NUL.


rstudio/reticulate documentation built on Nov. 18, 2024, 12:03 p.m.