Search code examples
c#pythonlinqenumerable

Python equivalent of C#'s .Select?


I've got an list of objects in Python, and they each have an id property. I want to get a list of those IDs.

In C# I'd write

myObjects.Select(obj => obj.id);

How would I do this in Python?


Solution

  • [obj.id for obj in myObjects]