mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-88275: Add missing __init__
method to match
example (#120281)
This commit is contained in:
parent
b41d79c776
commit
7a9d46295a
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
|
||||
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:
|
||||
x: int
|
||||
y: int
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def location(point):
|
||||
match point:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue