10000 gh-88275: Add missing `__init__` method to `match` example (#120281) · python/cpython@7a9d462 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a9d462

Browse files
authored
gh-88275: Add missing __init__ method to match example (#120281)
1 parent b41d79c commit 7a9d462

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Doc/whatsnew/3.10.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,12 @@ Patterns and classes
551551
552552
If you are using classes to structure your data, you can use as a pattern
553553
the class name followed by an argument list resembling a constructor. This
554-
pattern has the ability to capture class attributes into variables::
554+
pattern has the ability to capture instance attributes into variables::
555555
556556
class Point:
557-
x: int
558-
y: int
557+
def __init__(self, x, y):
558+
self.x = x
559+
self.y = y
559560
560561
def location(point):
561562
match point:

0 commit comments

Comments
 (0)
0