Releases: santinic/pampy
Releases · santinic/pampy
v0.2.1
Support for dataclasses in Python 3.7
Pampy supports Python 3.7 dataclasses. You can pass the operator _
as arguments and it will match those fields.
@dataclass
class Pet:
name: str
age: int
pet = Pet('rover', 7)
match(pet, Pet('rover', _), lambda age: age) # => 7
match(pet, Pet(_, 7), lambda name: name) # => 'rover'
match(pet, Pet(_, _), lambda name, age: (name, age)) # => ('rover', 7)