param
param copied to clipboard
Callback called before a method that is depended upon
The Dependencies and Watchers guide shows that you can depend on a method, as in the example below:
import param
class D(param.Parameterized):
x = param.Number(0)
@param.depends('x', watch=True)
def cb1(self):
print(f"cb1 x={self.x}")
@param.depends('cb1', watch=True)
def cb2(self):
print(f"cb2 x={self.x}")
d = D()
d.x = 5
Output:
cb1 x=5
cb2 x=5
However, if you swap the declaration of cb1 and cb2, cb2 is called first while I would have expected cb2 to always be called after cb1:
import param
class D(param.Parameterized):
x = param.Number(0)
@param.depends('cb1', watch=True)
def cb2(self):
print(f"cb2 x={self.x}")
@param.depends('x', watch=True)
def cb1(self):
print(f"cb1 x={self.x}")
d = D()
d.x = 5
Output:
cb2 x=5
cb1 x=5