▲ | zahlman 3 months ago | |||||||
A compromise version:
The `match` part could still be written using Python's if-expression syntax, too. But this way avoids having very long lines like in the Ruby example, and also destructures `item` to avoid repeatedly writing `item.`.I very frequently use this helper-function (or sometimes a generator) idiom in order to avoid building a temporary list to `.join` (or subject to other processing). It separates per-item processing from the overall algorithm, which suits my interpretation of the "functions should do one thing" maxim. | ||||||||
▲ | legobmw99 2 months ago | parent [-] | |||||||
I still think it is a shame that `match` isn't valid as an expression, requiring things like the helper function here that could be a lambda or part of a comprehension otherwise | ||||||||
|