I ran the following based on the sample code and got an error.
The sample code in the tutorial may be an excerpt of some code.
However, given that we will try "Point(1, var)" immediately following, I believe the user will easily understand that there is a necessary dataclass import statement.
class Point:
x: int
y: int
def where_is(point):
match point:
case Point(x=0, y=0):
print("Origin")
case Point(x=0, y=y):
print(f"Y={y}")
case Point(x=x, y=0):
print(f"X={x}")
case Point():
print("Somewhere else")
case _:
print("Not a point")
## Added code
p = Point(1, 1)
p = Point(1, 1)
^^^^^^^^^^^
TypeError: Point() takes no arguments
Documentation
This is a pull request for the sample code in section 4.6.
I ran the following based on the sample code and got an error.
The sample code in the tutorial may be an excerpt of some code.
However, given that we will try "Point(1, var)" immediately following, I believe the user will easily understand that there is a necessary dataclass import statement.
Executed code :
Errors that occurred :
Linked PRs