4 ms·
Idiomatic Python wouldn't use a map here, but a generator expression: (x.split('=')[1] for x in s.split('?')[1].split('&')[-3:]) Removing the lambda cuts
by gilch 4y ago
Idiomatic Python wouldn't use a map here, but a generator expression:
(x.split('=')[1] for x in s.split('?')[1].split('&')[-3:])
Removing the lambda cuts down on the noise considerably.
And honestly, with this many splits with fixed indexes, I'd probably use a regex. Now there's a dense language for you.
- chii 4y agoi don't really see why or how a generator expression is any easier to read than a chained call like the OP's example. In fact, for people unfamiliar with python, this expression is even more strange - you read expression starting from the middle (the _in_ ... part), and then return to the beginning. It makes your eye dart forward and backwards on the text.