Pythonic way to get some rows of a matrix
问题 I was thinking about a code that I wrote a few years ago in Python, at some point it had to get just some elements, by index, of a list of lists. I remember I did something like this: def getRows(m, row_indices): tmp = [] for i in row_indices: tmp.append(m[i]) return tmp Now that I've learnt a little bit more since then, I'd use a list comprehension like this: [m[i] for i in row_indices] But I'm still wondering if there's an even more pythonic way to do it. Any ideas? I would like to know