s2t.Path
May 7, 2026 ยท View on GitHub
description: A representation of a path in the expression.
s2t.Path
View source on GitHub
|
A representation of a path in the expression.
s2t.Path(
field_list: Sequence[s2t.Step]
)
Do not implement nonzero, eq, ne, et cetera as these are implicitly defined by cmp and len.
Args | |
|---|---|
| `field_list` | a list or tuple of fields leading from one node to another. |
Raises | |
|---|---|
| `ValueError` | if any field is not a valid step (see is_valid_step). |
Methods
as_proto
as_proto()
Serialize a path as a proto.
This fails if there are any anonymous fields.
| Returns | |
|---|---|
| a Path proto. |
concat
concat(
other_path: "Path"
) -> "Path"
get_child
get_child(
field_name: s2t.Step
) -> "Path"
Get the child path.
get_least_common_ancestor
get_least_common_ancestor(
other: "Path"
) -> "Path"
Get the least common ancestor, the longest shared prefix.
get_parent
get_parent() -> "Path"
Get the parent path.
| Returns | |
|---|---|
| The parent path. |
| Raises | |
|---|---|
| `ValueError` | If this is the root path. |
is_ancestor
is_ancestor(
other: "Path"
) -> bool
True if self is ancestor of other (i.e. a prefix).
prefix
prefix(
ending_index: int
) -> "Path"
suffix
suffix(
starting_index: int
) -> "Path"
__add__
__add__(
other: Union['Path', str]
) -> "Path"
__eq__
__eq__(
other: "Path"
) -> bool
Return self==value.
__ge__
__ge__(
other: "Path"
) -> bool
Return self>=value.
__gt__
__gt__(
other: "Path"
) -> bool
Return self>value.
__le__
__le__(
other: "Path"
) -> bool
Return self<=value.
__len__
__len__() -> int
__lt__
__lt__(
other: "Path"
) -> bool
Return self<value.
__ne__
__ne__(
other: "Path"
) -> bool
Return self!=value.
View source on GitHub