param.parameterized.Parameters.update#
- Parameters.update(arg=<Undefined>, /, **kwargs)[source]#
Update multiple parameters of this object or class before triggering events.
Allows setting the parameters of the object or class using a dictionary, an iterable, or keyword arguments in the form of param=value. The specified parameters will be updated to the given values.
This method can also be used as a context manager to temporarily set and then reset parameter values.
- Parameters:
**params (dict or iterable or keyword arguments) – The parameters to update, provided as a dictionary, iterable, or keyword arguments in param=value format.
Guide (User)
----------
https (//param.holoviz.org/user_guide/Parameters.html#other-parameterized-methods)
Examples
Create a Parameterized class:
>>> import param >>> class P(param.Parameterized): ... a = param.String() ... b = param.String()
Define the instance:
>>> p = P(a="0. Hello", b="0. World")
Use .update to update the parameters:
>>> p.param.update(a="1. Hello", b="2. World") >>> p.a, p.b ('1. Hello', '1. World')
Update the parameters temporarily:
>>> with p.param.update(a="2. Hello", b="2. World"): ... print(p.a, p.b) 2. Hello 2. World
>>> p.a, p.b ('1. Hello', '1. World')
Lets see that events are triggered after all parameters have been updated
>>> @param.depends(p.param.a, watch=True) ... def print_a_b(a): ... print(p.a, p.b) >>> my_param.param.update(a="3. Hello",b="3. World") 3. Hello 3. World