How to write a Python class using reticulate


How to write a Python class using reticulate?

1 Like

You can create classes in any python script, e.g. source_python('')

Functions and other data within Python modules and classes can be accessed via the $ operator (analogous to the way you would interact with an R list, environment, or reference class).
Some more details in this article; Introduction to reticulate.

Or perhaps I misunderstand the question?

I wish to create a class in .R instead of .py, like with function in R.

py <- import_builtins()
with(py$open("output.txt", "w") %as% file, {
  file$write("Hello, there!")