Question: In PHP I use the [array\_column()](http://php.net/manual/en/function.array-column.php) function a lot as it allows me to retrieve values from a specific column inside an array returned themselves in a nice array, for example, using this array:

```
$users = [
    [
        'id' => 1,
        'name' => 'Peter'
    ],
    [
        'id' => 2,
        'name' => 'Paul'
    ],
    [
        'id' => 3,
        'name' => 'John'
    ]
];

```

Doing `array_column($users, 'name')` will return:

```
Array
(
    [0] => Peter
    [1] => Paul
    [2] => John
)

```

Since transitioning to Python I still haven't found a built in function that I can use to do the same thing on a `list` of `dict`s for example. 

Does such a function exist and if not, what is the best way to achieve this?

Answer: 
You can use a list comprehension to extract the 'column' of interest. There is no direct Python function to my knowledge. List comprehensions are almost always faster than using `map`. [Python List Comprehension Vs. Map](https://stackoverflow.com/questions/1247486/python-list-comprehension-vs-map)

```
users = [
    {
        'id': 1,
        'name': 'Peter'
    },
    {
        'id': 2,
        'name': 'Paul'
    },
    {
        'id': 3,
        'name': 'John'
    }
]

>>> [(user.get('id'), user.get('name')) for user in users]
[(1, 'Peter'), (2, 'Paul'), (3, 'John')]

```

Or using an enumerated index location instead of the `id` field:

```
>>> [(n, user.get('name')) for n, user in enumerate(users)]
[(0, 'Peter'), (1, 'Paul'), (2, 'John')]

```

Or just the names...

```
>>> [user.get('name') for user in users]
['Peter', 'Paul', 'John']

```
Something like this?

```
arr = [
        {
        'id' : 1,
        'name' : 'Peter'
        },
    {
        'id' : 2,
        'name' : 'Paul'
    },
    {
        'id' : 3,
        'name' : 'John'
    }
]
list(map(lambda x: x["name"], arr))

```