You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/language/control-flow.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ for i in range(10):
101
101
break
102
102
if i %2==0:
103
103
continue
104
-
print(i)
104
+
print(i)
105
105
```
106
106
107
107
```text Output
@@ -128,7 +128,7 @@ done
128
128
129
129
Subset supported: literal patterns, capture variables, `_` wildcard, OR (`|`), guards (`if`), sequence patterns with `*rest`.
130
130
131
-
Sequence-pattern items must be literals (`int` / `float` / `str` / `True` / `False` / `None`), capture names, or `_`. Nested sequences (`case [[a, b], c]:`), mapping patterns (`{"key": x}`), class patterns (`Point(x=0)`), and `as` captures are unsupported, use chained `if` / `elif`.
131
+
Sequence-pattern items must be literals (`int` / `float` / `str` / `True` / `False` / `None`), capture names, or `_`. Nested sequences (`case [[a, b], c]:`), mapping patterns (`{"key": x}`), class patterns (`Point(x=0)`), and `as` captures are unsupported; use chained `if` / `elif` instead.
132
132
133
133
```python
134
134
defclassify(p):
@@ -165,11 +165,11 @@ span 1..5
165
165
defdescribe(n):
166
166
match n:
167
167
case0:
168
-
return"zero"
168
+
return"zero"
169
169
case1:
170
-
return"one"
170
+
return"one"
171
171
case _:
172
-
return"many"
172
+
return"many"
173
173
174
174
for x in [0, 1, 2, 99]:
175
175
print(describe(x))
@@ -246,7 +246,7 @@ except ValueError:
246
246
rejected
247
247
```
248
248
249
-
`raise X from Y` raises `X`. The `from` clause parses and the cause evaluates, but `__cause__` / `__context__` aren't preserved, only `X` reaches the handler.
249
+
`raise X from Y` raises `X`. The `from` clause parses and the cause evaluates, but `__cause__` / `__context__` aren't preserved; only `X` reaches the handler.
250
250
251
251
```python
252
252
try:
@@ -278,7 +278,7 @@ Pre-bound exception classes (with their parent links so `except <Parent>:` match
278
278
279
279
## with
280
280
281
-
`with` drives the context-manager protocol: evaluate the expression, call `__enter__`, bind the result to `as`. On exit, `__exit__(exc_type, exc_value, traceback)` runs,`(None, None, None)` on normal completion, live exception info on raise. Truthy return suppresses; falsy propagates. See [`/language/dunders`](/language/dunders).
281
+
`with` drives the context-manager protocol: evaluate the expression, call `__enter__`, bind the result to `as`. On exit, `__exit__(exc_type, exc_value, traceback)` runs:`(None, None, None)` on normal completion, live exception info on raise. Truthy return suppresses; falsy propagates. See [`/language/dunders`](/language/dunders).
0 commit comments