From 788cf4b3f1d19ea9409e0f8715bf3e69485b2821 Mon Sep 17 00:00:00 2001 From: Tomasz Kalinowski Date: Wed, 4 Sep 2024 21:54:17 -0400 Subject: [PATCH] Remove recommendation to implement `py_str()` methods. Package authors should implement the `print()`, `format()`, `summary()`, and/or `str()` methods in R directly for Python objects. --- vignettes/package.Rmd | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/vignettes/package.Rmd b/vignettes/package.Rmd index 695ea0c4e..410496119 100644 --- a/vignettes/package.Rmd +++ b/vignettes/package.Rmd @@ -115,17 +115,6 @@ method.MyModule.MyPythonClass <- function(x, y, ...) { Note that this check isn't required, as by default an R error will occur. If it's desirable to avoid this error for any reason then you can use `py_is_null_xptr()` to do so. -The **reticulate** package exports a `py_str` generic method which is called from the `str` method only after doing appropriate validation (if the object is NULL then `` is returned). You can implement the `py_str` method as follows: - -```r -#' @importFrom reticulate py_str -#' @export -py_str.MyModule.MyPythonClass <- function(object, ...) { - # interact with the object to generate the string -} -``` - -The `print` and `summary` methods for Python objects both call the `str` method by default, so if you implement `py_str()` you will automatically inherit implementations for those methods. ### Converting between R and Python