patma
patma copied to clipboard
Should we allow `*rest` in a class pattern?
The PEP currently allows Rectangle(*coordinates, painted=True), but does not specify semantics.
Is coordinates here an expression that provides constants to match some positional arguments? Or is it a name pattern that sets variable coordinates to all the positional arguments (which can be found via __match_args__)?
I think @ilevkivskyi probably meant the latter, but I misread it as the former. Maybe we're better off without it? That would also strengthen the argument against allowing **rest here -- if we have *args, why not **kwds? **kwds is hard to compute since we would have to enumerate all the attributes of the proxy returned by __match__(), and I don't expect it to be a common use case. For that matter I don't expect *args to be commonly needed either.
I think @ilevkivskyi probably meant the latter
Yes. But I am also fine with dropping this. Initial motivation was some symmetry with sequence/mapping pattern, but since we are not adding **rest, we may also drop *rest for now. These two are easy to add in future versions (if people will ask).
Okay, let's drop it. I had never even thought of this as an option before I saw your PEP.