(no title)
mar77i | 5 years ago
With all the metaprogramming that is possible, will the matching Cat(age=age) even produce a coherent object that has an age argument passed to __init__? Do keyword arguments in those patterns work on properties? How will it compare to another cat, is that using "is" or __eq__?
Does Cat have to derive from the same type object?
def Cat(**kwargs):
return type("Cat", (), {"__init__": lambda self, **kw: ([setattr(self, k, v) for k, v in kw.items()], None)[-1]})(**kwargs)
heavenlyblue|5 years ago
There’s a magic method called “match” that you can override to support matching.