Skip to content

Commit

Permalink
add pattern matching example to samples
Browse files Browse the repository at this point in the history
  • Loading branch information
fcheung committed Jul 28, 2023
1 parent 4c385e5 commit f9ef709
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/visual/samples/python
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,10 @@ def do_nothing():

app = FastAPI()
FastAPIInstrumentor.instrument_app(app)

# Structural pattern matching (PEP634)
match point:
case Point(x, y) if x == y:
print(f"The point is located on the diagonal Y=X at {x}.")
case Point(x, y):
print(f"Point is not on the diagonal.")

0 comments on commit f9ef709

Please sign in to comment.