Just taking a ride on the thread here,
I made a quick talk on the proposed feature for a local group,
and in the process I refactored a "real world" class I have in a
project, which features a complicated __init__ due having lots
of different, optional, ways to be initialized.
I can tell I liked what could be done -
reducing roughly 60 loc packed with "isinstance" calls,
"if/elif" blocks, temporary, intermediate state variables,
into 25 lines including 10 case-clauses that are very
straightforward to read.
Sorry for whoever would like an example differing much of the
"point2d" examples on the PEP, but the class in question IS geometry related
and is a Rectangle -
I am not yet testing (neither on the 'normal' if/else version)
_invalid_ arguments - there are a lot of way to pass
conflicting arguments to __init__ - and the if/elif logic
to handle those properly is not in place. The match/case
version for handling these invalid combinations would be
very straight forwad, on the other hand .
(all said, I think I still miss a way to mark variables that
are assigned in the case clauses, just for the record :-) )
Enough cheaptalk - links are here:
tests:
You will notice one "real world" pattern that was needed there: as the case clauses had
to be aware of values spread across different keyword-parameters, I had to prepend
a "packing" of all function arguments into a mapping to match against.
If I would not care for the function signature, I could just get "**kwargs" and match against that.