rbartpackages.base.rproperty¶
- rbartpackages.base.rproperty(meth, *, rname=None, wrap=None)[source]¶
Automatically implement a read-only property using the corresponding R field.
Unlike the attributes
RObjectBasesnapshots at initialization, the field is extracted from the R object at each access, so it tracks mutable objects such as reference-class instances.- Parameters:
meth (
FunctionType) – A method in a subclass ofRObjectBase. The original implementation is completely discarded.rname (
str|None, default:None) – The name of the field in R. If not specified, use the name ofmeth.wrap (
type[RObjectBase] |None, default:None) – ARObjectBasesubclass to wrap the field with, instead of converting it to a Python value.
- Returns:
property– A read-only property that extracts the field with R’s$operator. NULL fields are exposed asNone.
Examples
>>> class MyRObject(RObjectBase): ... _rfuncname = 'mypackage::myfunction' ... @partial(rproperty, rname='my.field') ... def my_field(self): ... ...