pygame-ce
pygame-ce copied to clipboard
Add `__match_args__` to `Event` for `type`
trafficstars
match statements are good for pygame events.
match event:
case Event(type=pygame.MOUSEBUTTONDOWN, pos=(x, y)):
print(x, y)
(Maybe that should be documented.)
If __match_args__ = ("type,") was added to Event, then type would be positional so that type= doesn't need to be written:
match event:
case Event(pygame.MOUSEBUTTONDOWN, pos=(x, y)):
print(x, y)
__match_args__ could also be added to classes like Rect and Vector2/3 but I don't think there are many use cases.
https://docs.python.org/3/tutorial/controlflow.html#match-statements