param
param copied to clipboard
`objects` set on both class and instance with `on_init=True`
With on_init=True
the objects
of the selector are set both on the instance and the class in the callback.
Code:
class P(param.Parameterized):
s = param.Selector()
@param.depends('s', watch=True, on_init=True)
def update(self):
self.param.s.objects = list('abc')
p = P()
p.param.s.objects
P.param.s.objects
The same error can be reproduced with setting up objects
before super
is called in a Parameterized constructor.
import param
class P(param.Parameterized):
s = param.Selector()
def __init__(self, **params):
self.param.s.objects = list('abc')
super().__init__(**params)
p = P()
assert P.param.s.objects == [] # Fails!
So there's a problem with how on_init
is implemented. And I wonder if there would be a way to warn or error when a Parameter attribute is changed before super
is called.
The issue in my first post was fixed:
Not in the second one though:
Honestly think the second behavior can't be supported properly, maybe we error there somehow.