Print parameter value each time it changes / identifying which parameter changed in @depends

Hi all,

for debugging purposes I’d like to get an exact chronology of which parameters is set with what value. Does param already have this capability? I know I could set some hook with @depends(..., watch=True) on every single parameter, but that’s tedious if I have to do it for every single parameter.

Is there maybe a way using depends that allows me to figure out which parameter it was that triggered the change, so I can pull that one out manually?

Thanks in advance!

Again, the docs have become really good since last time I checked, kudos to the dev team!

Here is a worked example very similar to what I want to do:

def e(e):
    return f"(event: {} changed from {e.old} to {})"

class P(param.Parameterized):
    a = param.Integer(default=0)
    b = param.Integer(default=0)
    def __init__(self, **params):
        super().__init__(**params), ['a'], queued=True, precedence=2), ['a'], precedence=1),  ['b'])

    def run_a1(self, event):
        self.b += 1
        print('a1', self.a, e(event))

    def run_a2(self, event):
        print('a2', self.a, e(event))

    def run_b(self, event):
        print('b', self.b, e(event))
p = P()

p.a = 1
1 Like