diff options
author | Nao Pross <np@0hm.ch> | 2024-03-02 18:17:10 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-02 18:17:10 +0100 |
commit | 9dc875e5e67835ad1974b52491a4b7af072d52a3 (patch) | |
tree | 64ab75e1193a981f883f1d74a1f5cf4379351141 | |
parent | Rewrite state type annotations to avoid circular import (diff) | |
download | mdpoly-9dc875e5e67835ad1974b52491a4b7af072d52a3.tar.gz mdpoly-9dc875e5e67835ad1974b52491a4b7af072d52a3.zip |
Add Expr.node to ease iteration expression tree node children
-rw-r--r-- | mdpoly/abc.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mdpoly/abc.py b/mdpoly/abc.py index 7ac21dd..c60311a 100644 --- a/mdpoly/abc.py +++ b/mdpoly/abc.py @@ -33,6 +33,9 @@ class Expr(Protocol): name = self.__class__.__qualname__ return f"{name}(left={self.left}, right={self.right})" + def nodes(self) -> Sequence[Self]: + return self.left, self.right + def leaves(self) -> Sequence[Leaf]: if isinstance(self.left, Leaf): yield self.left |