▲ | the-grump 8 days ago | |||||||||||||
You can express the loop as a list comprehension, and I would too. As for the logic, I would still use pattern matching for branching and destructuring, but I’d put it in a helper. More lines is not a negative in my book, though I admit the thing with convert and format is weird. | ||||||||||||||
▲ | pansa2 8 days ago | parent | next [-] | |||||||||||||
> I would still use pattern matching for branching and destructing, but I’d put it in a helper Yeah, using a helper function makes things much clearer. To be honest though, I'm not a huge fan of using either `isinstance` (which is generally a sign of a bad design) nor `match/case` (which is essentially a "modern" way to write `isinstance`). I can't help but think that a better design could avoid the need for either of those (e.g. via polymorphism). | ||||||||||||||
| ||||||||||||||
▲ | zahlman 8 days ago | parent | prev [-] | |||||||||||||
> As for the logic, I would still use pattern matching for branching and destructuring, but I’d put it in a helper. I wrote it up (https://news.ycombinator.com/item?id=43650001) before reading your comment :) |