FromIter
Bases: ABC
flowchart TD
pyochain.abc.constructors.FromIter[FromIter]
click pyochain.abc.constructors.FromIter href "" "pyochain.abc.constructors.FromIter"
Source code in pyochain/abc/constructors.pyi
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
from_iter(iterable)
abstractmethod
staticmethod
Create the instance from an Iterable.
Tip
For converting a literal tuple[T, ...] to a Seq[T], of is more efficient since it directly constructs the instance from the *elements tuple.
Keep in mind that it's an exception rather than the rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[I]
|
The iterable to create the instance from. |
required |
Returns:
| Type | Description |
|---|---|
FromIter[I]
|
FromIter[I]: A new instance containing the elements from the provided |
Example
from pyochain import Vec, Seq
assert Vec.from_iter([1, 2, 3]) == Vec(1, 2, 3)
assert Seq.from_iter((1, 2, 3)) == Seq(1, 2, 3)
assert Vec.from_iter("hello") == Vec("h", "e", "l", "l", "o")
Source code in pyochain/abc/constructors.pyi
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |