8000 [3.14] gh-88275: Add missing `__init__` method to `match` example (GH… · python/cpython@cca18fc · GitHub
[go: up one dir, main page]

Skip to content

Commit cca18fc

Browse files
[3.14] gh-88275: Add missing __init__ method to match example (GH-120281) (#134142)
gh-88275: Add missing `__init__` method to `match` example (GH-120281) (cherry picked from commit 7a9d462) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
1 parent b43e1d0 commit cca18fc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Doc/whatsnew/3.10.rst

Lines changed: 4 additions & 3 deletions
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