mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[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 7a9d46295a
)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
parent
b43e1d0b48
commit
cca18fcbe8
1 changed files with 4 additions and 3 deletions
|
@ -551,11 +551,12 @@ Patterns and classes
|
||||||
|
|
||||||
If you are using classes to structure your data, you can use as a pattern
|
If you are using classes to structure your data, you can use as a pattern
|
||||||
the class name followed by an argument list resembling a constructor. This
|
the class name followed by an argument list resembling a constructor. This
|
||||||
pattern has the ability to capture class attributes into variables::
|
pattern has the ability to capture instance attributes into variables::
|
||||||
|
|
||||||
class Point:
|
class Point:
|
||||||
x: int
|
def __init__(self, x, y):
|
||||||
y: int
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
|
||||||
def location(point):
|
def location(point):
|
||||||
match point:
|
match point:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue