4 ms·
The walrus operator is not the point; the existing constructs should be expanded, that way things make sense and are composable. E.g., pattern matching of this
by otabdeveloper4 6y ago
The walrus operator is not the point; the existing constructs should be expanded, that way things make sense and are composable.
E.g., pattern matching of this sort
for ["get", obj] | ["pick", "up", obj] | ["pick", obj, "up"] in list_of_get_commads:
...
IMO should have "just worked".
But now we have two different and incompatible versions of pattern matching in Python.
- oblvious-earth 6y agoThat's not an existing construct, it's a LHS assignment language like the match statement but it's embedded inside a for-loop. Which means you have to implement all the grammar of the current match and it restricts to only works on iterables. How would you implement this for an object that isn't iterable?