Bases: Function
Implementation of logical AND (&).
This class represents a logical AND operation that can be performed on
two or more arguments. It supports chaining of multiple AND operations
using the &
operator.
Parameters:
Name |
Type |
Description |
Default |
*args
|
Any
|
The arguments to be logically ANDed together. At least two arguments
are required.
|
()
|
Raises:
Type |
Description |
ValueError
|
If fewer than two arguments are provided.
|
Examples:
>>> a = And(Label.key == "k1", Label.value == "v1")
>>> b = And(Label.key == "k1", Label.value == "v2")
>>> c = a & b
Methods:
Name |
Description |
__and__ |
Supports chaining of multiple And operations using the & operator.
|
Source code in valor/schemas/symbolic/operators.py
| class And(Function):
"""
Implementation of logical AND (&).
This class represents a logical AND operation that can be performed on
two or more arguments. It supports chaining of multiple AND operations
using the `&` operator.
Parameters
----------
*args : Any
The arguments to be logically ANDed together. At least two arguments
are required.
Raises
------
ValueError
If fewer than two arguments are provided.
Examples
--------
>>> a = And(Label.key == "k1", Label.value == "v1")
>>> b = And(Label.key == "k1", Label.value == "v2")
>>> c = a & b
Methods
-------
__and__(other)
Supports chaining of multiple `And` operations using the `&` operator.
"""
def __init__(self, *args):
if len(args) < 2:
raise ValueError("Expected at least two arguments.")
super().__init__(*args)
def __and__(self, other: Any):
if isinstance(other, And):
self._args.extend(other._args)
else:
self._args.append(other)
return self
|