Skip to content

FromArgs

Bases: FromIter[T], ABC


              flowchart TD
              pyochain.abc.constructors.FromArgs[FromArgs]
              pyochain.abc.constructors.FromIter[FromIter]

                              pyochain.abc.constructors.FromIter --> pyochain.abc.constructors.FromArgs
                


              click pyochain.abc.constructors.FromArgs href "" "pyochain.abc.constructors.FromArgs"
              click pyochain.abc.constructors.FromIter href "" "pyochain.abc.constructors.FromIter"
            
Source code in pyochain/abc/constructors.pyi
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@type_check_only
class FromArgs[T](FromIter[T], ABC):
    @staticmethod
    @abstractmethod
    def of[E](*elements: E) -> FromArgs[E]:
        """Create the instance from a variable number of single elements `E`.

        Args:
            *elements (E): The elements to create the instance from.

        Returns:
            FromArgs[E]: A new instance containing the provided `elements`.

        Example:
            ```python
            from pyochain import Vec, Seq

            assert Vec.of(1, 2, 3) == Vec(1, 2, 3)
            assert Seq.of(1, 2, 3) == Seq(1, 2, 3)
            assert Seq.of([1, 2], 3) == Seq([1, 2], 3) == Seq.from_iter([[1, 2], 3])
            assert Seq.of("h", "e", "l", "l", "o") == Seq("h", "e", "l", "l", "o")
            ```
        """

of(*elements) abstractmethod staticmethod

Create the instance from a variable number of single elements E.

Parameters:

Name Type Description Default
*elements E

The elements to create the instance from.

()

Returns:

Type Description
FromArgs[E]

FromArgs[E]: A new instance containing the provided elements.

Example
from pyochain import Vec, Seq

assert Vec.of(1, 2, 3) == Vec(1, 2, 3)
assert Seq.of(1, 2, 3) == Seq(1, 2, 3)
assert Seq.of([1, 2], 3) == Seq([1, 2], 3) == Seq.from_iter([[1, 2], 3])
assert Seq.of("h", "e", "l", "l", "o") == Seq("h", "e", "l", "l", "o")
Source code in pyochain/abc/constructors.pyi
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@staticmethod
@abstractmethod
def of[E](*elements: E) -> FromArgs[E]:
    """Create the instance from a variable number of single elements `E`.

    Args:
        *elements (E): The elements to create the instance from.

    Returns:
        FromArgs[E]: A new instance containing the provided `elements`.

    Example:
        ```python
        from pyochain import Vec, Seq

        assert Vec.of(1, 2, 3) == Vec(1, 2, 3)
        assert Seq.of(1, 2, 3) == Seq(1, 2, 3)
        assert Seq.of([1, 2], 3) == Seq([1, 2], 3) == Seq.from_iter([[1, 2], 3])
        assert Seq.of("h", "e", "l", "l", "o") == Seq("h", "e", "l", "l", "o")
        ```
    """