param.reactive.reactive_ops.in_#
- reactive_ops.in_(other) rx[source]#
Check if the current object is contained βinβ the given operand.
This method performs a containment check, equivalent to the
inkeyword in Python, but within a reactive expression. The result is returned as a new reactive expression.- Parameters:
other (any) β The collection or operand to check for containment.
- Returns:
A new reactive expression representing the result of the containment check.
- Return type:
Examples
Check if a reactive value is in a list:
>>> import param >>> rx_value = param.rx(2) >>> rx_in = rx_value.rx.in_([1, 2, 3]) >>> rx_in.rx.value True
Check containment with a string:
>>> rx_char = param.rx('a') >>> rx_in = rx_char.rx.in_('alphabet') >>> rx_in.rx.value True
Update the reactive value and observe changes:
>>> rx_char.rx.value = 'c' >>> rx_in.rx.value False