
Last chance! 50% off unlimited learning
Sale ends in
Create a python class
PyClass(classname, defs = list(), inherit = NULL)
Name of the class. The class name is useful for S3 method dispatch.
A named list of class definitions - functions, attributes, etc.
A list of Python class objects. Usually these objects have
the python.builtin.type
S3 class.
if (FALSE) {
Hi <- PyClass("Hi", list(
name = NULL,
`__init__` = function(self, name) {
self$name <- name
NULL
},
say_hi = function(self) {
paste0("Hi ", self$name)
}
))
a <- Hi("World")
}
Run the code above in your browser using DataLab