3 ms·
> [p for mat in state_dict.values() for row in mat for p in row] I'm so happy without seeing Python list comprehensions nowadays. I don't know why they couldn
by ruszki 8mo ago
> [p for mat in state_dict.values() for row in mat for p in row]
I'm so happy without seeing Python list comprehensions nowadays.
I don't know why they couldn't go with something like this:
[state_dict.values() for mat for row for p]
or in more difficult cases
[state_dict.values() for mat to mat*2 for row for p to p/2]
I know, I know, different times, but still.
- deleted 8mo ago[deleted]
- WithinReason 8mo agoI would have gone for: [for p in row in mat in state_dict.values()]
- ruszki 8mo agoThat’s also an option. The left to right flow is better for the sake of autocomplete and comprehension: when you start to read your right to left version, you don’t know what is p, then row, then mat. With left to right, this problem doesn’t exist. One for sure, both are superior to the garbled mess of Python’s. Of course if the programming language would be in a right to left natural language, then these are reversed.