How do i make parameter readonly for user input but writeable in code?

I have a parametrized class and some of the parameters should never be changed by a user. They should be shown only. But the code should be able to update them.

How do I enable that?

Example

If the user clicks the below button the TypeError: Constant parameter 'mean_365d_30d_rolling' cannot be modified error is shown. How do I avoid that and allow the code to change the value?

image

import panel as pn
import param


def update(features):
    features.mean_365d_30d_rolling += 1


class SpreadFeatures(param.Parameterized):
    mean_365d_30d_rolling = param.Number(1.0, constant=True)
    std_365_30d_rolling = param.Number(1.0)
    action = param.Action(update)


features = SpreadFeatures()
pn.Param(features).servable()

I’d certainly like to make this easier somehow but currently you can do this:

def update(features):
    with param.edit_constant(features):
        features.mean_365d_30d_rolling += 1

It works. Thanks.

And I think the api for it is OK. Would not spend time on changing it. But maybe it should be documented somewhere?