PyDocs

Nav

Python Language Services

MatchAs

ast

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