Skip to content

PyoContainer

Bases: Container[T], ABC


              flowchart TD
              pyochain.abc._collection.PyoContainer[PyoContainer]

              

              click pyochain.abc._collection.PyoContainer href "" "pyochain.abc._collection.PyoContainer"
            

ABC for collections.abc.Container Protocol.

Source code in src/pyochain/abc/_collection.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class PyoContainer[T](Container[T], ABC):
    """ABC for `collections.abc.Container` Protocol."""

    # pyrefly: ignore [implicit-any-attribute]
    __slots__ = ()  # pyright: ignore[reportUnannotatedClassAttribute]

    def contains(self, value: T) -> bool:
        """Check if the `Container` contains the specified **value**.

        This is equivalent to using the `in` keyword directly on the `Container`.

        Args:
            value (T): The value to check for existence.

        Returns:
            bool: True if the value exists in the Collection, False otherwise.

        Example:
            ```python
            >>> from pyochain import Dict
            >>> data = Dict.from_ref({1: "a", 2: "b"})
            >>> data.contains(1)
            True
            >>> data.contains(3)
            False

            ```
        """
        return value in self

contains(value)

Check if the Container contains the specified value.

This is equivalent to using the in keyword directly on the Container.

Parameters:

Name Type Description Default
value T

The value to check for existence.

required

Returns:

Name Type Description
bool bool

True if the value exists in the Collection, False otherwise.

Example
>>> from pyochain import Dict
>>> data = Dict.from_ref({1: "a", 2: "b"})
>>> data.contains(1)
True
>>> data.contains(3)
False
Source code in src/pyochain/abc/_collection.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def contains(self, value: T) -> bool:
    """Check if the `Container` contains the specified **value**.

    This is equivalent to using the `in` keyword directly on the `Container`.

    Args:
        value (T): The value to check for existence.

    Returns:
        bool: True if the value exists in the Collection, False otherwise.

    Example:
        ```python
        >>> from pyochain import Dict
        >>> data = Dict.from_ref({1: "a", 2: "b"})
        >>> data.contains(1)
        True
        >>> data.contains(3)
        False

        ```
    """
    return value in self