PyDocs

Nav

Python Language Services

MatchOr

ast

class · Added in 3.10
  • MatchOr(patterns)
MatchOr(pattern* patterns)
1 Example
>>> print(ast.dump(ast.parse("""
... match x:
...     case [x] | (y):
...         ...
... """), indent=4))
Module(
    body=[
        Match(
            subject=Name(id='x'),
            cases=[
                match_case(
                    pattern=MatchOr(
                        patterns=[
                            MatchSequence(
                                patterns=[
                                    MatchAs(name='x')]),
                            MatchAs(name='y')]),
                    body=[
                        Expr(
                            value=Constant(value=Ellipsis))])])])
from the Python docs
See Also
No see-alsos for ast/MatchOr
0 Notes
No notes for MatchOr