from contextlib import contextmanager
except Exception as e:
print(type(e).__name__, ':', e)
rp = param.Parameter(1, readonly=True)
c = param.Parameter(1, constant=True)
n = param.Parameter(1)
P.rp = 2
p = P()
p.rp = 2
# Ok before instantiation
P.c = 2
# Ok during instantiation
p = P()
p.c = 4
# This is not so well known to Param users, Parameters act as class variables
# if not set in the constructor or after instantiation.
p1 = P()
p2 = P()
# Modifying the class value will only affect the Parameters that have constant=False (default)
P.n = P.c = 10
@maximlt — thanks, yes that example is very clear.
I suppose really the names should have been the other way around if anything, because ‘constant’ is the one that is ‘readonly’ for the user, and the one that is not actually constant because it can be edited with edit_constant. But anyway, things have their history and turn out as they do for what must have been good reasons at some point.